How to pass data from Controller to Zend Form

To pass data from your controller, to a Zend_Form, you can utilise the config parameters:

$this->view->form = new Contact_Edit_Form(array('contactName' => 'Chris'));

This will pass a very simple array to the form, and from within the form,

$data = $this->getAttrib('contactName');

$data will then contain Chris


3 comments on “How to pass data from Controller to Zend Form

  1. Mark September 25, 2013 2:27 pm

    Thanks dude for this simple and efficient trick!

  2. rajasekar April 3, 2016 10:23 am

    i need to pass a value to the form from controller,
    in that form it should be hidden field,
    after some process again the all data need to post in controller is possible?

  3. rajasekar April 3, 2016 10:51 am

    thanks i solve that issue, but i need again to post the value in controller

    $data = $this->getAttrib(‘userID’)
    this is my form code

    i need to post this value in controller is it possible

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.