Zend Framework

Chapter "19.9.2. Multi-Page Forms" has code examples with some wrong code

Details

  • Type: Docs:  Problem Docs: Problem
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: Zend_Form
  • Labels:
    None
  • Language:
    English

Description

The Code example below has the wrong class definition:

Multi-page forms code example
class My_Form_Registration extends Zend_Form
{
    // ...
    
    /**
     * Is the sub form valid?
     * 
     * @param  Zend_Form_SubForm $subForm 
     * @param  array $data 
     * @return bool
     */
    public function subFormIsValid(Zend_Form_SubForm $subForm,
                                   array $data)
    {
        $name = $subForm->getName();
        if ($subForm->isValid($data)) {
            $this->getSessionNamespace()->$name = $subForm->getValues();
            return true;
        }

        return false;
    }

    /**
     * Is the full form valid?
     * 
     * @return bool
     */
    public function formIsValid()
    {
        $data = array();
        foreach ($this->getSessionNamespace() as $key => $info) {
            $data[$key] = $info;
        }

        return $this->getForm()->isValid($data);
    }
}

Instead, it should show:

Multi-page forms code example - correct
class RegistrationController extends Zend_Controller_Action
{
    // class contents...

Activity

Hide
Matthew Weier O'Phinney added a comment -

Corrected in trunk; thanks for the report.

Show
Matthew Weier O'Phinney added a comment - Corrected in trunk; thanks for the report.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: