Modal call controller action

So, I'm kind off new to frameworks and to Phalcon PHP. I have this "login/signup" modal. If I register or login I want to call my registerAction() in the UsersController. The problem is that the modal should be called from anywhere in my website so for that reason I can't really change the URL to use routing to access my controller actions. I'm not sure what the best solution for my modal problem is. I'll post the modal code below. Hope someone knows about the best to use solution.

            {#Login button#}
            <ul class="nav navbar-nav pull-right">
                <li><a href="users" data-toggle="modal" data-target="#login-modal1">Login</a></li>
            </ul>

            {#Login pop-up#}
            <div class="modal" id="login-modal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

                <div class="modal-dialog">

                    <div class="loginmodal-container" id="hide">

                        <h1>Login to Your Account</h1><br>

                        <form method="post">
                            <input type="text" name="" placeholder="Username" />
                            <input type="password" name="" placeholder="Password" />
                            <input type="submit" name="" class="login loginmodal-submit" value="Login" />
                        </form>

                        <div class="login-help">
                            <a data-dismiss="modal" data-toggle="modal" data-target="#login-modal2" href="users">Register</a> - <a href="#">Forgot Password</a>
                        </div>

                    </div>

                </div>

            </div>

            <div class="modal" id="login-modal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-  hidden="true">

                <div class="modal-dialog">

                    <div class="loginmodal-container">

                        <h1>Register</h1><br>

                        <form method="post">
                            <input type="text" name="user" placeholder="Username" />
                            <input type="password" name="password" placeholder="Password" />
                            <input type="password" name="email" placeholder="E-Mail" />
                            <input type="submit" name="login" class="login loginmodal-submit" value="Register" />
                        </form>

                        <div class="login-help">
                            Already have an account? <a data-dismiss="modal" data-toggle="modal" data-target="#login-modal1">Sign in</a>
                        </div>

                    </div>

                </div>

            </div>


2.9k
edited Feb '17

I'd add a route to specifically call the controller and action.

use Phalcon\Mvc\Router;
$router = new Router();
$router->add(
    "/login/signup",
    array(
        "controller"    => "users",
        "action"        => "register"
    )
)->via( array("POST") );

Then whenever you want to hit that action, direct the user to http://localhost/login/signup (with a POST request method)

For example

<form method="post" action="/login/signup">
 ....
</form>

Or have I misunderstood?

edited Feb '17
//modal with volt syntax
{{ form('login/signup', 'method':'post') }}
    {{ text_field('login', 'id':'login') }}
    {{ text_field('password' 'id':'login') }}
    {{ submit_button('class':'bt') }}
 {{ end_form() }}

If you want the modal in all pages put them into views/index.volt