Should i be able to simply use $form->populate($data); to set the selected
item of a Zend_Form_Element_Select object?
I have this in the form;
// Add the machine type element
$this->addElement('select', 'machinetype', array(
'id' => 'text',
'multiOptions' => array('Cutting', 'Punching', 'Bending',
'Welding'),
'label' => 'Type:',
'required' => true,
'filters' => array('StringTrim','StringToUpper'),
'validators' => array(array('StringLength', false, array(0,1)))
));
Then I have this in the controller;
$data = array(
'id' => $row->GetId(),
'machinetype'=> 'Welding', //$row->getMachinetype(),
'name' => $row->getName(),
'descr' => $row->getDescr()
);
$form->populate($data);
$this->view->form = $form;
return;
However when using the controller the 'machinetype' always gets set to
'Cutting'. i.e. the first item in the list, when it should get set to
'Welding'.
Is $form->populate() not enough?
Steve R
Williams Refrigeration is a trading name of AFE Group Limited.
Registered in England & Wales under Registered Number 3872673. Registered
Office Address - Bryggen Road, North Lynn, Industrial Estate, Kings Lynn,
Norfolk, PE30 2HZ
Williams Refrigeration reserves the right to block any email attachment we deem
inappropriate and to also reject any inbound connections from Blacklisted
servers. Any email meeting the above criteria will be automatically rejected
without notification given to the original sender.
NOTE: In accordance with the Data Protection Act compliance, all Bulk sends
should use the BCC field as much as possible.
This e-mail and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed. If
you have received this email in error or are having trouble sending email to
Williams please notify the system administrator -
[email protected]
Any views or opinions expressed in this e-mail are those of the sender and do
not necessarily coincide with those of Williams Refrigeration or the AFE Group.