views:

250

answers:

1

I'm using Zend_Form with a ViewScript decorator. This form will be for managing two fairly simple types of objects but is a big form so I'd like to have a single form / processing function.

So I have this:

class GameManagementForm extends Zend_Form{

public function __construct($type='flash'){
 parent::__construct();

   //and later
    $this->setDecorators( array( array('ViewScript', array('viewScript' => 'game/game-management.phtml'))));

What I would like to do is be able to pass non Zend_Form varaiables to the viewScript. I tried passing a referencing to $this but no such luck. Is there a way to call something like this:

$this->setDecorators( array( array('ViewScript', array('viewScript' => 'game/game-management.phtml', $arg))));

thanks for help

+2  A: 

According to the API Docs any options set on the decorator besides separator, placement, and viewScript will be passed to the viewScript as local variables. So:

 $this->setDecorators(array(array('ViewScript', array(
      'viewScript' => 'game/game-management.phtml',
      'foo' => 'bar'
 ))));

And then in your viewScript 'foo' should be 'bar'.

smack0007
cool thanks. would be this->foo in the ViewScript in case anybody stumbles across this. for arrays of data i would just do 'foo'=>$args (although probably obvious.
timpone
Yes, forgot to mention the $this.
smack0007