framework for creating forms, phplib good, are there any options?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gonzalo briceno

    framework for creating forms, phplib good, are there any options?

    I have been using phplib for a while and I really like the framework
    except for form creation. Maybe it is me but I in my opinion there
    isn't a good way to create forms or should I say, everything else is
    so well done that the way you create forms seems to be too cumbersome,
    in particular making it so that a pull down menu selects a value that
    you assign it.
    In any case, does anyone know of any php based (or other readily
    accepted web language) solution to creating forms?

    Any suggestions are welcome
  • Manuel Lemos

    #2
    Re: framework for creating forms, phplib good, are there any options?

    Hello,

    On 11/09/2004 01:26 AM, gonzalo briceno wrote:[color=blue]
    > I have been using phplib for a while and I really like the framework
    > except for form creation. Maybe it is me but I in my opinion there
    > isn't a good way to create forms or should I say, everything else is
    > so well done that the way you create forms seems to be too cumbersome,
    > in particular making it so that a pull down menu selects a value that
    > you assign it.
    > In any case, does anyone know of any php based (or other readily
    > accepted web language) solution to creating forms?[/color]

    You may want to try this popular forms generation and validation class:




    --

    Regards,
    Manuel Lemos

    PHP Classes - Free ready to use OOP components written in PHP
    Free PHP Classes and Objects 2025 Versions with PHP Example Scripts, PHP Tutorials, Download PHP Scripts, PHP articles, Remote PHP Jobs, Hire PHP Developers, PHP Book Reviews, PHP Language OOP Materials


    PHP Reviews - Reviews of PHP books and other products


    Metastorage - Data object relational mapping layer generator

    Comment

    • Eric Brongers

      #3
      Re: framework for creating forms, phplib good, are there any options?

      I can recommend PEAR. It's allmost PHPLIB compatible, modular and has a form
      creation class.

      Regards,

      Eric Brongers

      "gonzalo briceno" <gonzalobriceno @gmail.com> schreef in bericht
      news:5a17c7bd.0 411081926.4111b 42a@posting.goo gle.com...[color=blue]
      > I have been using phplib for a while and I really like the framework
      > except for form creation. Maybe it is me but I in my opinion there
      > isn't a good way to create forms or should I say, everything else is
      > so well done that the way you create forms seems to be too cumbersome,
      > in particular making it so that a pull down menu selects a value that
      > you assign it.
      > In any case, does anyone know of any php based (or other readily
      > accepted web language) solution to creating forms?
      >
      > Any suggestions are welcome[/color]


      Comment

      • Henk Verhoeven

        #4
        Re: framework for creating forms, phplib good, are there any options?

        gonzalo briceno wrote:[color=blue]
        > I have been using phplib for a while and I really like the framework
        > except for form creation. Maybe it is me but I in my opinion there
        > isn't a good way to create forms or should I say, everything else is
        > so well done that the way you create forms seems to be too cumbersome,
        > in particular making it so that a pull down menu selects a value that
        > you assign it.
        > In any case, does anyone know of any php based (or other readily
        > accepted web language) solution to creating forms?
        >
        > Any suggestions are welcome[/color]

        You could use phpPeanuts, but that will require that you embrace OOP
        within the environment (architecture?) of the framework. If you do, it
        will not only generate forms with dropdown lists, search dialogs,
        checkboxes, and navigational links to related objects, but also convert
        datatypes, validate user data, report user data entry mistakes, if no
        mistakes modify your objects, save them to MySql, retrieve them, cache
        them, search for them, page the results, and generate some default reports.

        But OTOH, you need basic OOP knowledge (the website does NOT offer an
        entry level course OOP). And still the paradigm leap you have to make
        may be a bridge too far. Furthermore you may have trouble integrating it
        with existing databases and application code. And once you really get
        the hang of it, you are likely to percieve your 'old' code as 'legacy'
        that urgently needs refactoring or rebuilding. But OK, if you are
        learning rapidly (i believe most people here do) the last will probably
        happen anyway ;-)

        Greetings,

        Henk Verhoeven,
        www.phpPeanuts.org.

        BTW, there are many more frameworks in php, see
        The page you are looking for could not be found. Return to HotScripts homepage to browse our collection of PHP, CGI, Perl, JavaScript and ASP scripts.


        Comment

        • gonzalo briceno

          #5
          Re: framework for creating forms, phplib good, are there any options?

          Thanks to everyone with replies; I'm looking into your suggestions.
          For those that are already using PHPLIB I have the following code to
          generate a pull-down menu and have the particular choice <select>ed
          assuming that there is a database record with this information. Note
          that my code is tab delimited with 2 spaces per tab so if you copy and
          paste the code into a text editor everything should look a lot nicer.

          1. This is the function(borrow ed from php.net) that queries
          table.field and produces an array of values for this field ASSUMING
          that it is either of enum or set type.

          function mysql_enum_valu es(&$db, $tableName,$fie ldName)
          {
          $result = $db->query("DESCRIB E $tableName");

          //then loop:
          while($row = mysql_fetch_arr ay($result))
          {
          //# row is mysql type, in format "int(11) unsigned zerofill"
          //# or "enum('cheese', 'salmon')" etc.

          ereg('^([^ (]+)(\((.+)\))?([
          ](.+))?$',$row['Type'],$fieldTypeSpli t);
          //# split type up into array
          $ret_fieldName = $row['Field'];
          $fieldType = $fieldTypeSplit[1];// eg 'int' for integer.
          $fieldFlags = $fieldTypeSplit[5]; // eg 'binary' or 'unsigned
          zerofill'.
          $fieldLen = $fieldTypeSplit[3]; // eg 11, or 'cheese','salmo n' for
          enum.

          if (($fieldType==' enum' || $fieldType=='se t') &&
          ($ret_fieldName ==$fieldName) )
          {
          $fieldOptions = split("','",sub str($fieldLen,1 ,-1));
          return $fieldOptions;
          }
          }

          //if the funciton makes it this far, then it either
          //did not find an enum/set field type, or it
          //failed to find the the fieldname, so exit FALSE!
          return FALSE;
          }

          2. This is the code that goes into the PHP page that uses PHPLIB's
          templates and ooforms. We are using blocks to automate creation of
          certain form elements.
          include "template.i nc";
          $t1 = new Template();
          $t1->set_file("MyFi leHandle","pull downs_blocks.ht ml");
          $defaults = array (
          "message" => "Testing the pull down menu option",
          "action" => "inquiry_manage 2.php",
          "search_for " => "Search for an inquiry where the person's name is"
          );
          $t1->set_var($defau lts);
          //Pull the 'highest_educat ion' field from the 'Business_Appli cation'
          table and show a pull down

          $db = new DB_Example();
          $result = $db->query("SELEC T `highest_educat ion` , `business_plan` ,
          `business_age`
          FROM `Business_appli cation`
          WHERE `ID` =51");

          //if($result)
          $row = mysql_fetch_ass oc($result);

          foreach ($row as $element => $value) {
          //set the blocks
          $t1->set_block("MyF ileHandle", "blk_".$element , $element);
          //get the choices for Business_applic ation.element to populate the
          pull down menu
          $choice = mysql_enum_valu es($db, "Business_appli cation",$elemen t);
          //output the pull down menu
          foreach($choice as $x)
          {
          if ($x == $value) {
          $t1->set_var($eleme nt."_value", "value='".$ x."' selected");
          $t1->set_var($eleme nt."_text", $x);
          }
          else {
          $t1->set_var($eleme nt."_value", "value='".$x."' ");
          $t1->set_var($eleme nt."_text", $x);
          }
          $t1->parse($element , "blk_".$element , TRUE);
          }
          }
          $t1->parse("MyOutpu t","MyFileHandl e");
          $t1->p("MyOutput" );

          3. This is the actual HTML page with the block definitions. Please
          note that blocked sections are named 'blk_<element>' and the
          corresponding record field is called <element> so that I can parse the
          file with the line
          $t1->parse($element , "blk_".$element , TRUE);

          <table border=0 width="100%">
          <tr>
          <td>
          <SELECT name="highest_e ducation">
          <!-- BEGIN blk_highest_edu cation -->
          <option {highest_educat ion_value}>{hig hest_education_ text}</option>
          <!-- END blk_highest_edu cation -->
          </SELECT>
          </td>
          </tr>
          <tr>
          <td>
          <SELECT name="business_ plan">
          <!-- BEGIN blk_business_pl an -->
          <option {business_plan_ value}>{busines s_plan_text}</option>
          <!-- END blk_business_pl an -->
          </SELECT>
          </td>
          </tr>
          <tr><td valign="top">su bmit</td><td><input name='submit'
          value='submit' type='submit'></td></tr>
          </table>

          Henk Verhoeven <news@phppeanut sREMOVE-THIS.org> wrote in message news:<cmrjee$51 g$1@news6.zwoll 1.ov.home.nl>.. .[color=blue]
          > gonzalo briceno wrote:[color=green]
          > > I have been using phplib for a while and I really like the framework
          > > except for form creation. Maybe it is me but I in my opinion there
          > > isn't a good way to create forms or should I say, everything else is
          > > so well done that the way you create forms seems to be too cumbersome,
          > > in particular making it so that a pull down menu selects a value that
          > > you assign it.
          > > In any case, does anyone know of any php based (or other readily
          > > accepted web language) solution to creating forms?
          > >
          > > Any suggestions are welcome[/color]
          >
          > You could use phpPeanuts, but that will require that you embrace OOP
          > within the environment (architecture?) of the framework. If you do, it
          > will not only generate forms with dropdown lists, search dialogs,
          > checkboxes, and navigational links to related objects, but also convert
          > datatypes, validate user data, report user data entry mistakes, if no
          > mistakes modify your objects, save them to MySql, retrieve them, cache
          > them, search for them, page the results, and generate some default reports.
          >
          > But OTOH, you need basic OOP knowledge (the website does NOT offer an
          > entry level course OOP). And still the paradigm leap you have to make
          > may be a bridge too far. Furthermore you may have trouble integrating it
          > with existing databases and application code. And once you really get
          > the hang of it, you are likely to percieve your 'old' code as 'legacy'
          > that urgently needs refactoring or rebuilding. But OK, if you are
          > learning rapidly (i believe most people here do) the last will probably
          > happen anyway ;-)
          >
          > Greetings,
          >
          > Henk Verhoeven,
          > www.phpPeanuts.org.
          >
          > BTW, there are many more frameworks in php, see
          > http://www.hotscripts.com/PHP/Script...ork/index.html[/color]

          Comment

          • Michael Fesser

            #6
            Re: framework for creating forms, phplib good, are there any options?

            .oO(gonzalo briceno)
            [color=blue]
            >1. This is the function(borrow ed from php.net) that queries
            >table.field and produces an array of values for this field ASSUMING
            >that it is either of enum or set type.
            >
            >function mysql_enum_valu es(&$db, $tableName,$fie ldName)
            >{
            > $result = $db->query("DESCRIB E $tableName");
            >[...][/color]

            You could use the following query to fetch informations for the
            requested field directly:

            SHOW COLUMNS FROM $tableName LIKE '$fieldName'

            Then parse the returned Type-field.

            Micha

            Comment

            • Mike Walsh

              #7
              Re: framework for creating forms, phplib good, are there any options?


              "gonzalo briceno" <gonzalobriceno @gmail.com> wrote in message
              news:5a17c7bd.0 411081926.4111b 42a@posting.goo gle.com...[color=blue]
              > I have been using phplib for a while and I really like the framework
              > except for form creation. Maybe it is me but I in my opinion there
              > isn't a good way to create forms or should I say, everything else is
              > so well done that the way you create forms seems to be too cumbersome,
              > in particular making it so that a pull down menu selects a value that
              > you assign it.
              > In any case, does anyone know of any php based (or other readily
              > accepted web language) solution to creating forms?
              >
              > Any suggestions are welcome[/color]

              I like phpHtmlLib - http://phphtmllib.newsblob.com

              The help/documentation is pretty good and there are a number examples you
              can
              look at.

              Mike


              --
              Mike Walsh - mike_walsh at mindspring.com


              Comment

              Working...