Note that there are some explanatory texts on larger screens.

plurals
  1. POLoading models in Zend_Form using Zend Framework
    primarykey
    data
    text
    <p>I'm trying to build a form using the Zend_Form component, but the number of elements varies. The information for each Zend_Form element is stored in a database (name, options, validators, filters, etc.).</p> <p>The application I'm working on consists of building surveys which contain a varying number of questions. Each question is associated with different arrays of answers. Ultimately my goal is to build arrays of radio/checkbox buttons, dynamically, server-side.</p> <p>I'm looking for a pretty way to generate my form, but I'm not sure of the best way to load the model within the form. Should the model be loaded in the controller then passed (somehow, via a parameter?) directly to the form, or is it better to load the model within the Form init() method? Where's the best place to put the logic, should it be within the form class, or within the controller, or within the model?</p> <p>My idea is to fetch form element properties (name, rules, filters, etc.) in the database, then iterate and finally render the form. What do you think of this approach? Ultimately, elements will be dynamically added (client-side), this time, using AJAX and a JavaScript library (such as jQuery).</p> <p>Here are a couple useful links I found via Google, but I think they all answer a slightly different question than mine:</p> <p>On building dynamic forms, server side:</p> <ul> <li><a href="http://framework.zend.com/wiki/display/ZFPROP/Zend_Form+generation+from+models+-+Jani+Hartikainen" rel="nofollow noreferrer">http://framework.zend.com/wiki/display/ZFPROP/Zend_Form+generation+from+models+-+Jani+Hartikainen</a></li> <li><a href="http://weierophinney.net/matthew/archives/200-Using-Zend_Form-in-Your-Models.html" rel="nofollow noreferrer">http://weierophinney.net/matthew/archives/200-Using-Zend_Form-in-Your-Models.html</a></li> <li><a href="http://codeutopia.net/blog/2009/01/07/another-idea-for-using-models-with-forms/" rel="nofollow noreferrer">http://codeutopia.net/blog/2009/01/07/another-idea-for-using-models-with-forms/</a></li> </ul> <p>On building dynamic forms, client side, with AJAX processing:</p> <ul> <li><a href="http://www.jeremykendall.net/2009/01/19/dynamically-adding-elements-to-zend-form/" rel="nofollow noreferrer">http://www.jeremykendall.net/2009/01/19/dynamically-adding-elements-to-zend-form/</a></li> </ul>
    singulars
    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.
 

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