views:

182

answers:

2

Ahh forgive my Zend newbness, I'm trying to access this form, stored in:

layouts/scripts/layout.phtml:

$this->layout()->userForm = $this->action('index', 'user');

within

class IndexController extends Zend_Controller_Action
{
    public function init ()
    {    /* Initialize action controller here */
    }
    public function indexAction ()
    {
    // here
    }
}

The indexAction, I basically need the form to show up on the homepage in addition to being in the layout.

I tried accessing it with $this->_helper->layout()->userForm but I suspect the code in the controller runs before the layout as it wasn't giving me what I wanted.

+1  A: 

I think

$this->_helper->layout->userForm

should do it.

after I don't know why you don't reuse the

 $this->action('index', 'user');

in your view appears to be more much simple IMHO.

RageZ
yes I tried this but it seems like it doesn't spit anything out, which is why I suspect the controller code runs before the layout properties get set possibly?
meder
yeah the layout would probably run last, anyway you should not put code in the layout just my feeling.
RageZ
+3  A: 

I don't understand your question really.

  • Why by all means is your form stored in the layout folder?
  • What do you mean with 'show up on the homepage in addition to being in the layout'? Seems you haven't got the same definition of 'layout' as Zend. The layout as I understand it, contains all your contents and segments so the sentence doesn't make sense.
  • why wouldn't you just initiate the form and pass it to the view?

Like so:

$userForm = new UserForm();   
$this->view->userForm = $userForm;
tharkun