Say you have the following form for adding types of poop to [whatever]. On
this form, you don't know how many types of poop the user may want to add,
so you have a bit of javascript that simply adds elements to the DOM when
the user clicks a "Add Another Type" button. This could result in the
following:
<input type="text" name="type[]" />
<input type="text" name="type[]" />
<input type="text" name="type[]" />
This could be iterated by doing the following:
foreach($_POST['type'] as $type) {
// access value here ($type)
}
>From what I can tell, accessing dynamic fields on the server side cannot be
done using Zend_Form.
It would be so nice to be able to do something like this:
$poop = new Zend_Form();
$type = new Zend_Form_Element_Text('type', array(
'validators' => array('NotEmpty', ... etc),
'filters' => array('StringTrim', ... etc)
))
$poop->addElement($type);
and follow up the code with something like...
foreach ($type as $singleType) {
// Handle data here
}
--
View this message in context:
http://www.nabble.com/Dynamically-adding-%22Zend_Form_Elements%22-to-DOM-tp16930111p16930111.html
Sent from the Zend Framework mailing list archive at Nabble.com.