'Twas brillig, and denadai2 at 30/04/09 10:58 did gyre and gimble:
I've a problem: using getvalues i have an empty array as returned values.
This appens if i submit the correct form, an empty form or if i put some
chars.


$form = new forms_RegisterForm();

      if ($this->getRequest()->isPost())
      {
          $values = $form->getValues();
          print_r($values);
        if ($form->isValid($_POST))
        {

        }
        else
        {
            $form->populate($values);
        }
      }

Look at the examples again. You've not told your form where the values are coming from. It doesn't know that you want to get them from POST, so it's effectively not populated yet.

You can populate it manually, but it doesn't make much sense in your example above. Calling isValid() will populate the form with the values you give it.

Try:

if ($this->getRequest()->isPost())
{
  if ($form->isValid($this->getRequest()->getPost()))
  {
    $values = $form->getValues();
    print_r($values);
    ...
  }
}

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

Reply via email to