That's correct, the form cannot populate its own values because it knows
nothing about $_POST or $_GET. Your controller must pass that to the form.
If you're also using validation in your forms, there's a shortcut you can
use that checks if the data is valid and populates the form:

if ($form->isValid($this->_request->getPost())) {
    // process form using values from $form->getValues();
} else {
    // show validation errors to user
}

--
Hector


On Mon, Sep 21, 2009 at 1:03 PM, Anders Gunnarsson <[email protected]>wrote:

> For those who get the same problem,
> I solved it by populating the post again.
>
> $form->populate($_POST);
>
> It still feels like I'm doing something wrong,
> but this works for now.
>
>
>
> Anders Gunnarsson skrev:
>
>  Unfortunately that didn't help.
>>
>> The $_POST gives me
>> ['groups'] => Array ( [0] => 2 [1] => 3 [2] => 4 )
>>
>> But $form->getValues() still gives me
>> ['groups'] =>
>>
>>
>>
>>
>> Sergio Rinaudo skrev:
>>
>>>
>>> Hi,
>>> I am not sure if this is your solution, but after you instanciate the
>>> form, try to set RegisterInArrayValidator to false
>>>
>>>
>>> $form = new Your_Form(); // just an example
>>> $form->groups->setRegisterInArrayValidator(false);
>>>
>>> Give it a try.
>>> Bye
>>>
>>>
>>>
>>>
>>> > Date: Mon, 21 Sep 2009 16:58:15 +0200
>>> > From: [email protected]
>>> > To: [email protected]
>>> > Subject: [fw-general] Zend_Form_Element_MultiCheckbox values
>>> >
>>> > Hi
>>> >
>>> > My checked checkboxes are missing in the Post.
>>> >
>>> > I'm making checkboxes like this:
>>> >
>>> > $group = new Zend_Form_Element_MultiCheckbox('groups');
>>> > $group->addMultiOption(1,'A');
>>> > $group->addMultiOption(2,'B');
>>> > $group->addMultiOption(3,'C');
>>> > $form->addElement($group);
>>> >
>>> > They look good in the html, and when posted I can see "groups" as an
>>> > array in $_POST,
>>> > but just an empty string when looking in the
>>> > $form->getValues()
>>> >
>>> > What do I need to do to make the checkboxes appere in
>>> $form->getValues() ?
>>> >
>>> > regards
>>> > Anders
>>>
>>> ------------------------------------------------------------------------
>>> Preparati alla sfida all'ultima combinazione, gioca con Crosswire! <
>>> http://livesearch.games.msn.com/crosswire/default_it/>
>>> ------------------------------------------------------------------------
>>> Scarica Messenger gratis: comunica, divertiti e condividi rapidamente! <
>>> http://messenger.it/home_comunica.aspx>
>>>
>>
>>

Reply via email to