We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Redirect back to modal

i have a form in modal and after submission i validate the data , how can i redirect back to the modal if validation fails...? Please help..!!!!



85.5k

Because i have no idea what packages you are using, here is an bootstrap example that should do the trick

$(document).ready(function(){
    var $modal = $("#myModal");
    if (document.location.hash === "invalidRegisterForm"){
        $modal.modal("open"); // check this cuz i have forgotten how exactly was the bootstrap API
    }
});

in the controller you need to redirect to something like this

www.aaaaa.com/user/register#invalidRegisterForm


85.5k
edited Apr '17

or another was is in volt or whatever


if false === form.isValid() {
    <script type="text/javascript>
        var modal .. modal.open()
    </script>
}

but putting form in modals is one of the stupidiest ideas I have ever came up with :D