Categories
Zend Framework 1.12

Zend_form populate() not working?

Zend_form populate() not working

Below are a few reasons and a method for correcting: Zend_form populate() not working

1. Get the record used to populate

$myModel = new Model_My();
$id = $this->_request->getparam('id');
$record = $myModel->find($id)->current();

2. Make Sure is the form of key value pairs array

Zend_Debug::dump($record->toArray());

3. Make Sure you are calling correctly

$frmResource = new Form_Resource();
$formName->populate($record->toArray());
$this->view->form = $frmResource;

4. Make Sure the Names and Case of the array keys and form elements match.
ie.
$module = $this->createElement('text', 'module');
should have
["module"] => string(5) "admin"