Accessing controller data from a partial viewscript

When using an inline partial viewscript in my form, I sometimes need access to data. I can accomplish this by using a setter and getter with a public function in my form. We’ll use the action “guinness” as the controller action in this example.


protected $_id;

public function setId($id)
    $this->_id = $id;
    return $this;

public function getId()
    return $this->_id;

public function getPintCount()
    $model = new PubModel();
    return $model->countPints(this->getId());




$form = new SomeForm();




This way I can get the content view my connected partials which in essence are a copy of the viewscript.

Seems a long way round, but it keeps everything nicely separated.




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.