Submit A Form From Layouts/main.php

Can we submit a form from the layouts/main.php? If so can anyone give a flow on submitting from the layouts/main.php. I don’t want Ajax submission, i expect a way of direct post to the controller action.

Thanks in advance


Is any one aware of this , i have posted it a long time ago and i see no replies.

It’s no good idea to place a form in layouts/main.php.

The layout should only be used as wrapper for the controller views and add the common elements of all views (header, metatags, including css …).

See Basics Views

How do i continue if i have my login on the header? Any ideas?

Depends on:

  • What do you want to display instead of the loginform, if the user is logged in?

  • The logout button?

  • Visible on each page of your application?

A possible solution:

I would not place the loginform directly in the layouts/main.php, but do a renderPartial








    $this->renderPartial(''); //the standard loginform of the SiteController

//or $this->renderPartial(''); //an extra login view for the frontend 

//or $this->renderPartial('//layouts/_loginform'); //place an extra loginform in the layouts folder


The "_" indicates that the view is included by renderPartial.

Convention not requirement, but a good idea.

Okay, Thank you guys for the posts.