Zend_form Decorator / passing parameters

I have a form that extends from Zend_Form. I put the form in the ViewScript decorator as follows:

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

I would like to pass a variable to this view, but I do not know how to do this.

Since the partial view is in the form of a Zend_View (allowing $ this-> app_store_icon for rendering), there seems to be a way to pass the variables that need to be rendered. I tried the following, but to no avail.

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

Any help on how to do this would be appreciated.

thanks

+5
source share
3 answers

This is a bit complicated, it took me half an hour to figure it out, but it can be done :)

, ViewScript, . :

$this->setDecorators(array(array('ViewScript', array(
    'viewScript' => 'test.phtml',
    'foo'=>'baz',
))));

:

$this->setDecorators(array(array('ViewScript', array(
    'viewScript' => 'test.phtml',
    array(
        'foo'=>'baz',
        'spam'=>'ham',
    ),
))));

, test.phtml:

$option = $this->element->getDecorator('ViewScript')->getOptions();

$option['foo'], - $option[0]['foo']

HTH:)

+10

, , , ,

( , ). .

HtmlTag, , src .

, , , viewcript.

( , ), , viewscript , !

+2

html-, viewscript.phtml. , , , zend script. :

<Controller>
// pass status and score to view
$this->view->status = $this->_sitenamehelper->get_status($id);
$this->view->score = $this->_sitenamehelper->get_score($id);

<viewscript.phtml partial file>
<?php $form = $this->element; ?>
<b>Status: </b><?php echo $form->getView()->status; ?>
<b>Score: </b><?php echo $form->getView()->score; ?>

HTML-. , .

Mohannad

+2

All Articles