We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16085
    • 203 Posts
    he’s still working on it! but given the responses he’ll be keen to get something out before the weekend.
      • 14138
      • 13 Posts
      Hello All!

      Yes, I am now ready to release the 0.2 release of db2form!


      Change log:


      0.2 - Added WHERE parameter for SELECT query filtering
      - Changed INSERT titles to labels rather that p tags
      - Added PHP 4 compatibility for stripos function (thanks to AndeasT)
      - Printing field name titles can now cope with ’_’ and ’-’ as a spacer
      - Added templatable pagination controls to select queries
      - Max length and length of text fields are now automatically generated from MySQL field length
      - Accesskeys for html form fields are generated using a tasty new algorithm

      0.1 - Initial release



      Required parameters:


      &table -required
      set the full table name that you wish to use in the html form

      &type -required -defaults to ’select’
      options:

      &type=’select’ -- view and edit form (SELECT query)
      &type=’insert’ -- create new record form (INSERT query)
      set the type of form which is displayed

      &redirect -required -defaults to current page
      Accepts the document ID of the page you wish to redirect to.
      After an insert query has been successful, redirect to this page.

      Optional parameters:


      &title -defaults to modx current page title -optional
      display h1 text above your html form

      &where -defaults to ’’ -only available for use when &type=`select` -optional
      filter the results of a select query in this parameter using a TV`

      can use &order_by - for records ordering
      and &limit - to limit results

      &error_warn -defaults to ’warn’
      the css class for a html p tag displaying validation errors

      &success_msg -defaults to ’A new record has been added to $table’
      on a successful insert, this message will display at the top of the form

      &per_page -defaults to ’10’
      in a select query, use this to enable pagination
        • 1535
        • 84 Posts
        Great work!

        There is however another PHP 5-only function in the 0.2 release, str_split.

        I inserted the following substitute in the "if (PHP_VERSION < 5) {" clause in db2form_instantform.php to perform the function in PHP 4, but it is not a 100% replacement, and only works when the split_length parameter is 1. (which it is here)

        function str_split($str,$notused){
        return preg_split('#(?<=.)(?=.)#s', $str);
        


        I know it is possible to construct a 100% replacement, but this works good enough as far as I can see.

        Cheers,

        Andreas
          • 1535
          • 84 Posts
          It would be great to be able to limit the fields returned by the SELECT too. As far as I can tell, the whole table except for the keys is returned.

          Cheers,

          Andreas
            • 14138
            • 13 Posts
            Hiya,

            Thanks a lot for your input AndreasT.

            The php5 -> 4 hack function is now installed, and works with php versions < 5.

            I am now working on the field selection parameter for the SELECT view.

            The next version will have edit capabilities for records. So on a select query, you can hit ’edit’ at the side of the record, and the snippet will load up another page, to edit just that record.

            Are there any other improvements that could be made to this?

            Thanks a lot, your all helping tons!
            Andy
              • 1535
              • 84 Posts
              Cool that you are working on editing.

              I got a few suggestions.

              1. Ability to define the header labels by parameter.

              2. Align form cells to top, or by parameter.


              Cheers,

              Andreas
                • 14138
                • 13 Posts
                Thanks for all the interest, and sorry for the late slow development with this snippet! I’m a University student so my work comes first.

                When I get a free hour or two, I’ll spend it furthering the development of version 0.3 .

                Cheers
                  • 18082
                  • 8 Posts
                  hello,

                  i was just wondering how the edit/delete part of this was going?

                  Thanks for doing such an awesome job so far!

                  Regards.
                    • 14138
                    • 13 Posts
                    hiya malissa, and thanks for the interest!!

                    The edit part is getting there... I have the php ready, but not yet working -- I’m a little stuck with it.

                    The edit/delete record feature will definitely be in the next release version, im just not sure when that’ll be.

                    Following is a link to a semi-working but extremely buggy 0.3 pre-alpha version for you to tinker with.

                    http://www.microplop.com/db2form-0.3.zip

                    To get it working, setup a simple SELECT form grab, and the snippet will display ’edit’ links at the top of the form (but they should be next to the record itself). This will form the basis of an non-editable (yet) UPDATE query form for any MySQL table.

                    Delete will come later, but this should be a bit easier (i.e. no user input except the id to delete)

                    Thanks a lot!
                    Andy grin

                      • 28825
                      • 61 Posts
                      This is an awesome snippet! It’s great for people like me that want to develop a really custom solution for our websites! wink

                      Keep at it! grin
                        "Don&#39;t waste your time or time will waste you"