You can do:
- $this->firstName->getValue()
- $this->getElement('firstName')->getValue()
On Thu, Mar 19, 2009 at 5:59 PM, Ed Lazor <edlazor@internetarchitects.biz> wrote:
In your controller,
$form->populate($_POST)
or
$form->populate($form->getValues())
I think one of those will work.
On Thu, Mar 19, 2009 at 3:53 PM, Kevin Nelson <kev.nelson@live.com> wrote:
> 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'
> )
> ));
>
> ....
>
> ----------------------------------------------------------
> my controller:
>
> public function editAction()
> {
> $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());
>
> return $this->_helper->redirector('index');
> }
> }
>
> $this->view->form = $form;
> }
>
--
Cory Wiles
kwylez@gmail.com
http://www.corywiles.com/
http://www.randomthoughtprocess.com/
没有评论:
发表评论