<p>I'm currently playing around with <a href="http://pear.php.net/package/HTML_QuickForm" rel="noreferrer">HTML_QuickForm</a> for generating forms in PHP.  It seems kind of limited in that it's hard to insert my own javascript or customizing the display and grouping of certain elements.</p>

<p>Are there any alternatives to QuickForm that might provide more flexibility?</p>

[{'answer_id': 60372, 'author': 'Konrad Rudolph', 'author_id': 1968, 'author_profile': 'https://Stackoverflow.com/users/1968', 'pm_score': 4, 'selected': True, 'text': '<p>If you find it hard to insert Javascript into the form elements, consider using a JavaScript framework such as <a href="http://www.prototypejs.org/" rel="nofollow noreferrer">Prototype</a> or <a href="http://jquery.com/" rel="nofollow noreferrer">jQuery</a>. There, you can centralize the task of injecting event handling into form controls.</p>\n\n<p>By that, I mean that you won\'t need to insert event handlers into the HTML form code. Instead, you register those events from somewhere else. For example, in Prototype you would be able to write something like this:</p>\n\n<pre><code>$(\'myFormControl\').observe(\'click\', myClickFunction)\n</code></pre>\n\n<p>Also have a look at the answers to <a href="https://stackoverflow.com/questions/34126/whats-the-best-way-to-add-event-in-javascript">another question</a>.</p>\n\n<p>/EDIT: of course, you can also insert custom attributes and thus event handlers into the form elements using HTML_QuickForm. However, the above way is superior.</p>\n'}, {'answer_id': 60384, 'author': 'Kieran Hall', 'author_id': 6085, 'author_profile': 'https://Stackoverflow.com/users/6085', 'pm_score': 3, 'selected': False, 'text': '<p>I\'ve found the <a href="http://framework.zend.com/manual/en/zend.form.html" rel="nofollow noreferrer">Zend_Form</a> package of the <a href="http://framework.zend.com" rel="nofollow noreferrer">Zend Framework</a> to be particulary flexible.    This component can also be used with <a href="http://framework.zend.com/manual/en/zend.dojo.html" rel="nofollow noreferrer">Zend_Dojo</a> to rapidly implement common javascript form helpers.  However, the component is agnostic when it comes to the library that you use, but supports Dojo naitively.  The component also allows for grouping, multi-page forms, custom decorators, validators and other features making it very flexible.</p>\n'}, {'answer_id': 62035, 'author': 'Andrew Taylor', 'author_id': 1776, 'author_profile': 'https://Stackoverflow.com/users/1776', 'pm_score': 1, 'selected': False, 'text': '<p>I\'ll second Zend_Form; it has an excellent ini style implementation that allows you to define a form extremely quickly:</p>\n\n<pre><code>[main]\nvessel.form.method = "post"\n\nvessel.form.elements.name.type = "text"\nvessel.form.elements.name.name = "name"\nvessel.form.elements.name.options.label = "Name: "\nvessel.form.elements.name.options.required = true\n\nvessel.form.elements.identifier_type.type = "select"\nvessel.form.elements.identifier_type.name = "identifier_type"\nvessel.form.elements.identifier_type.options.label = "Identifier type: "\nvessel.form.elements.identifier_type.options.required = true\nvessel.form.elements.identifier_type.options.multioptions.IMO Number = "IMO Number";\nvessel.form.elements.identifier_type.options.multioptions.Registry organisation and Number = "Registry organisation and Number";\nvessel.form.elements.identifier_type.options.multioptions.SSR Number = "SSR Number";\n\nvessel.form.elements.identifier.type = "text"\nvessel.form.elements.identifier.name = "identifier"\nvessel.form.elements.identifier.options.label = "Identifier: "\nvessel.form.elements.identifier.options.required = true\nvessel.form.elements.identifier.options.filters.lower.filter = "StringToUpper"\n\nvessel.form.elements.email.type = "text"\nvessel.form.elements.email.name = "email"\nvessel.form.elements.email.options.label = "Email: "\nvessel.form.elements.email.options.required = true\n\nvessel.form.elements.owner_id.type = "hidden"\nvessel.form.elements.owner_id.name = "owner_id"\nvessel.form.elements.owner_id.options.required = true\n\n; submit button\nvessel.form.elements.submit.type = "submit"\nvessel.form.elements.submit.name = "Update"\nvessel.form.elements.submit.option.value = "Update"\n</code></pre>\n'}, {'answer_id': 473995, 'author': 'gavinandresen', 'author_id': 58359, 'author_profile': 'https://Stackoverflow.com/users/58359', 'pm_score': 2, 'selected': False, 'text': '<p>I wrote an article about this for OnLamp:  <a href="http://www.onlamp.com/pub/a/php/2006/03/16/autofill-forms.html" rel="nofollow noreferrer">Autofilled PHP Forms</a></p>\n\n<p>My beef with HTML_QuickForm and Zend_Form and all the other form-handling frameworks I could find is that they seem to assume that you\'ll be writing code to generate the form.  But that didn\'t match my development process, where I\'d start with the LOOK of the page (specified via HTML templates) and add functionality to it.</p>\n\n<p>In my view of the world, form handling boils down to:</p>\n\n<ol>\n<li>Fetching the data that should go in the form to start (usually from a database).</li>\n<li>Fetching the HTML code for the form (usually a template).</li>\n<li>Mushing 1 and 2 together, and outputting the result.</li>\n<li>Getting the submitted form data and validating it.</li>\n<li>Re-displaying the form with error messages and the invalid data, OR</li>\n<li>Displaying the congratulations-your-data-was-ok page.</li>\n</ol>\n\n<p>fillInFormValues() makes 2, 3, and 5 really easy.</p>\n'}, {'answer_id': 663432, 'author': 'blockhead', 'author_id': 60223, 'author_profile': 'https://Stackoverflow.com/users/60223', 'pm_score': 1, 'selected': False, 'text': "<p>With Zend_Form it is entirely possible to start with your form visually, and then work backwords.</p>\n\n<p>This is done by removing all decorators and replacing them with a ViewScript decorator</p>\n\n<pre><code>$this-&gt;form-&gt;setDecorators( array(array('ViewScript', array('viewScript' =&gt; 'forms/aform.phtml'))));\n</code></pre>\n\n<p>And in that viewscript you would do something like this:</p>\n\n<pre><code>&lt;?=$this-&gt;element-&gt;title-&gt;renderViewHelper()?&gt;\n</code></pre>\n\n<p>Going with this approach, you can basically do anything you want with the form.</p>\n\n<p>Another great thing about Zend_Form is that you can create custom elements which can encapsulate other stuff in them. For example, you can have an element which outputs a textarea and then some Javascript to turn it into a WYSIWYG area.</p>\n"}, {'answer_id': 663571, 'author': 'Sean McSomething', 'author_id': 39413, 'author_profile': 'https://Stackoverflow.com/users/39413', 'pm_score': 0, 'selected': False, 'text': '<p>I can\'t really say anything about it but, the other day, I ran across the <a href="http://www.phpformclass.com/page/index" rel="nofollow noreferrer">clonefish</a> form library.  It looked promising enough to end up in my bookmarks list as a "look at this later".</p>\n'}]
['https://Stackoverflow.com/questions/60369', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4883/']