Ok, I'm having a hard time finding anything on how to populate my edit form...
I know I have to have something in my controller class to pass the values to my form, but I can not find any reference anywhere on what to use for this...
thanks for any help...
my form is:
class Form_Edit_Contact extends Zend_Form
{
{
....
/**
* Input: First Name
*/
$this->addElement('text', 'firstName', array(
'label' => 'First Name:',
'required' => true,
'value' => $this->entry['firstName'], //Ive tried a few things here, none worked lol
'filters' => array('StringTrim'),
'validators' => array(
'Alpha'
)
));
* Input: First Name
*/
$this->addElement('text', 'firstName', array(
'label' => 'First Name:',
'required' => true,
'value' => $this->entry['firstName'], //Ive tried a few things here, none worked lol
'filters' => array('StringTrim'),
'validators' => array(
'Alpha'
)
));
....
----------------------------------------------------------
my controller:
public function editAction()
{
$request = $this->getRequest();
$form = $this->_getEditForm();
$model = $this->_getModel();
$this->view->entry = $model->fetchEntry($this->_getParam('id'));
{
$request = $this->getRequest();
$form = $this->_getEditForm();
$model = $this->_getModel();
$this->view->entry = $model->fetchEntry($this->_getParam('id'));
if ($this->getRequest()->isPost())
{
{
if ($form->isValid($request->getPost()))
{
{
$model = $this->_getModel();
$model->save($form->getValues());
$model->save($form->getValues());
return $this->_helper->redirector('index');
}
}
$this->view->form = $form;
}
}
}
$this->view->form = $form;
}
没有评论:
发表评论