-- Mathieu Suen <[email protected]> wrote
(on Friday, 17 July 2009, 01:48 PM +0200):
> I am using a ViewScript decorator on a Zend_Form but i can't get the  
> form from the view script.
>
> Here is the code:
>
>
> demogForm.phtml
> ___
> ...
> <?php
>  echo $this->form //Notice: Trying to get property of non-object ...
> ?>
> ...
> ___
>
>
> MyForm.php
> ___
> $this->setDecorators(array( array('ViewScript', array('viewScript' =>  
> 'demogForm.phtml'))));
> ___
>
>
> I have inspected the $this object in the view but it seems that there is  
> no property.

Since the ViewScript decorator can be used with forms, elements, and
display groups alike, it sets the "element" property on the view, not
the form property.

I typically do this at the top of such view scripts:

    <?php $form = $this->element; ?>

and then just reference $form from there on.

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/

Reply via email to