Zend_Form tiene una riqueza de funcionalidad, has a wealth of functionality, muchas de ellas diregidas
a expertos desarroladores. Este capítulo tiene por objeto al documento algunas de estas
funcionalidades con ejemplos y casos de uso.
Zend_Form attempts to automate this process with its
sub forms. By
default, sub forms render using the array notation as shown in the
previous HTML form listing, complete with ids. The array name is
based on the sub form name, with the keys based on the elements
contained in the sub form. Sub forms may be nested arbitrarily deep,
and this will create nested arrays to reflect the structure.
Additionally, the various validation routines in
Zend_Form honor the array structure, ensuring that your
form validates correctly, no matter how arbitrarily deep you nest
your sub forms. You need do nothing to benefit from this; this
behaviour is enabled by default.
Zend_Form::setIsArray($flag): By setting the
flag true, you can indicate that an entire form should be
treated as an array. By default, the form's name will be
used as the name of the array, unless
setElementsBelongTo() has been called. If the
form has no specified name, or if
setElementsBelongTo() has not been set, this
flag will be ignored (as there is no array name to which
the elements may belong).
isArray() accessor.
Zend_Form::setElementsBelongTo($array):
Using this method, you can specify the name of an array to
which all elements of the form belong. You can determine the
name using the getElementsBelongTo() accessor.
Zend_Form_Element::setBelongsTo() method.
To discover what this value is -- whether set explicitly or
implicitly via the form -- you may use the
getBelongsTo() accessor.
Zend_Form; however, most support for implementing them
is available and can be utilized with a little extra tooling.
Zend_Session_Namespace to persist data, which will
also help us answer the question of which form to submit.
$subForm =
$this->getCurrentSubForm();" to retrieve the current
sub form for validation, or "$next =
$this->getNextSubForm();" to get the next one to
display.
getCurrentSubForm() to determine
if any sub forms have been submitted (false return values
indicate none have been displayed or submitted), and
getNextSubForm() to retrieve a form to display. We
can then use the form's prepareSubForm() method to
ensure the form is ready for display.
Here is the information you provided:
// Have to do this construct due to how items are stored in session // namespaces foreach ($this->info as $info): foreach ($info as $form => $data): ?>