We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Combining multiple forms/controllers on a single page

Hi guys, I'm trying to learn phalcon by examining the examples. Currently I'm studying Vokura example.

What I want to do is, instead of going to Login and Signup pages seperately, I'd like to have them on one page, say index..

I've looked at Partial templates and tried to use:

<div>{{ partial("session/login") }}</div>
<div>{{ partial("session/signup") }}</div>

I also included:

use Vokuro\Forms\LoginForm;
use Vokuro\Forms\SignUpForm;

However, that threw an error Notice: Undefined variable: form

My question is, what do I need to do to include both login and signup forms on the index page without making changes to LoginForm.php, SignupForm.php, SessionController.php so I can also use links to go to the individual login and signup pages.

Hope I'm making any sense, thank you in advance.


Hello my friend... if you create a user is everything good? i am taking this error Fatal error: Maximum function nesting level of '100' reached, aborting! in C:\wamp\www\vokuro\app\controllers\SessionController.php on line 37 have you noticed anything?

@Cboursinos by answering my question with an unrelated question, you are taking away the bounty. Your question has nothing to do with this post and contributes nothing to the question. You should open a new discussion and ask your question there so phalcon community can view it and hopefully answer it.


Hi PersyJack,

Did you set those forms as view variable in your action? You need to do something like: $this->view->form = new MyFormClass(); and only then you will have 'form' variable in you templates/partials.


Hi @Arius. That's setup in the SessionController. After setting up $form = new LoginForm(); it sets up form elements and at the end calls $this->view->form = $form I still haven't figure this out and it seems no one knows how to do that. I think I'll give up on this


@PersyJack I think you don't fully understand the idea behind MVC in this case. IndexController doesn't have any informations from SessionController. They are separate scopes. IIf you want to have those forms generated in partials you need to initialize them in controller/action where you are showing them or inject those forms in other way.

In your indexController/indexAction you can use:

$signUpForm = new SignUpForm(); $this->view->signUpForm = $signUpForm;


$loginForm = new LoginForm(); $this->view->loginForm = $loginForm;

of course use loginForm and signUpForm variables instead form in your partials.

Or you can create service like:

$di->set("loginForm", function() { return new Vokuro\Forms\LoginForm(); });

$di->set("signUpForm", function() { return new Vokuro\Forms\SignUpForm(); });

and use those services in partials instead view variable. Honestly there are more and more ways :)