meder omuraliev
meder omuraliev

Reputation: 186562

Zend - access layout property from controller

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.

Upvotes: 2

Views: 1467

Answers (2)

markus
markus

Reputation: 40675

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;

Upvotes: 4

RageZ
RageZ

Reputation: 27313

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.

Upvotes: 1

Related Questions