no.
Change "in my controller" to the following
in my controller
==================
$data = array('location' => 'location1');
$form = $this->_getTestForm();
$form->populate($data);
...
....
==================
all i did was change the array
from
$data = array('location1' => 'location1');
to
$data = array('location' => 'location1');
does it work now?
Deepak Shrestha wrote:
>
> On Sat, Jan 31, 2009 at 10:48 PM, Daniel Latter <[email protected]>
> wrote:
>> Are you sure your setting $this->data variable in the form class?, and
>> if so var_dump it to see what it contains?
>>
>
> My sample trial code
>
> in my controller
> ==================
> $data = array('location1' => 'location1');
> $form = $this->_getTestForm();
> $form->populate($data);
> ...
> ....
> ==================
>
> in my form
> ===========================================
> $location = New Zend_Form_Element_Select('location');
> $location->setLabel('*Location:');
> foreach($this->data as $loc) //<<<<<<<<<
> {
> $adlocation->addMultiOption($loc);
> }
> ...
> ...
> ===========================================
>
> Now I expect that the select element in the form be pouplated with a
> value showing 'location1' but nothing gets in there instead error
> message is shown at the bottom of the form [Invalid argument supplied
> for foreach()]
>
> I have another select element in the form, which is hand coded.
> $myopts->setMultiOptions(array('option1' => 'option1', 'option2' =>
> 'option2'));
>
> This second select gets rendered correctly in the form.
>
> so what's going on?
>
> Thank a lot
>
> --
> =======================
> Registered Linux User #460714
> Currently Using Fedora 8, 10
> =======================
>
>
--
View this message in context:
http://www.nabble.com/Populating-Zend_Form_Element_Select-from-database-example-tp21761696p21764599.html
Sent from the Zend Framework mailing list archive at Nabble.com.