Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To be honest I wouldn't roll my own, considering there are a few mature form packages out there for PHP.</p> <p>I use PEAR's HTML_QuickForm package (<a href="http://pear.php.net/manual/en/package.html.html-quickform.php" rel="noreferrer">http://pear.php.net/manual/en/package.html.html-quickform.php</a>) for PHP4 sites.</p> <p>For PHP5, I'd have a look into Zend_Form (<a href="http://framework.zend.com/manual/en/zend.form.html" rel="noreferrer">http://framework.zend.com/manual/en/zend.form.html</a>).</p> <p>For my quickform code, I use a helper class that lets me define forms using a config array. For example:</p> <pre><code>echo QuickFormHelper::renderFromConfig(array( 'name' =&gt; 'area_edit', 'elements' =&gt; array( 'area_id' =&gt; array('type' =&gt; 'hidden'), 'active' =&gt; array('type' =&gt; 'toggle'), 'site_name' =&gt; array('type' =&gt; 'text'), 'base_url' =&gt; array('type' =&gt; 'text'), 'email' =&gt; array('type' =&gt; 'text'), 'email_admin' =&gt; array('type' =&gt; 'text'), 'email_financial' =&gt; array('type' =&gt; 'text'), 'cron_enabled' =&gt; array('type' =&gt; 'toggle'), 'address' =&gt; array('type' =&gt; 'address'), ), 'groups' =&gt; array( 'Basic Details' =&gt; array('site_name', 'base_url'), 'Address Details' =&gt; array('address'), 'Misc Details' =&gt; array(), // SM: Display the rest with this heading. ), 'defaults' =&gt; $site, 'callback_on_success' =&gt; array( 'object' =&gt; $module, 'function' =&gt; 'saveSite', ), )); </code></pre> <p>Note that the above element types 'address' and 'toggle' are in fact multiple form fields (basically, meta-types). This is what I love about this helper class - I can define a standard group of fields with their rules (such as address, credit_card, etc) and they can be used on lots of pages in a consistent fashion.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload