-- J DeBord <[email protected]> wrote
(on Friday, 24 April 2009, 04:33 PM +0200):
> Is there a method available to make Zend_Form sticky in the event it isn't
> valid? I came up with the code below, but couldn't determine if there was
> something already built in to Zend_Form  for doing this.
> 
> if (!$form->isValid($data)) {

isValid() populates the elements; there's nothing more that needs to be
done.

>     $elements = $form->getElements();
> 
>     foreach ($elements as $element) {
>         if ( !isset($data[$element->getName()]) ) {
>             continue;
>         }
>         $element->setValue($data[$element->getName()]);
>     }
>     $this->view->form = $form;
>     return $this->render('subscribe');
> 
> } else {
> 
> // VALID FORM
> 
> }

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/

Reply via email to