Thursday, March 16, 2017

How to redirect to Registration modal(bootstrap modal) window when AuthController found validation error/'s?

I'm currently using Laravel built-in authentication system. But I'm not using any specific page for User registration rather I'm using a bootstrap modal. My code works with my expectation only when the registration informations(input values) are correct.

But I want to redirect to registration modal window when the input fields values are invalid and want to show errors.

I'm attaching my codes as well as images for better understanding:

The code inside bootstrap modal window:

<button type="button" class="mdl-button mdl-js-button mdl-js-ripple-effect" data-toggle="modal" data-target="#registerModal">Register</button>

<div class="modal registerModal" id="registerModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h4 class="modal-title" id="myModalLabel">User Registration</h4>
      </div>
      <form action="" method="POST">
      <div class="modal-body">
          <div class="form-group">
            <div class="row">
              <div class="col-md-3"><label for="name">Name:</label></div>
              <div class="col-md-9"><input type="text" name="name" class="form-control" id="name" placeholder="Your name"></div>
            </div>
            <br>
            <div class="row">
              <div class="col-md-3"><label for="email">Email:</label></div>
              <div class="col-md-9"><input type="email" name="email" class="form-control" id="email" placeholder="Your email **This should be unique**"></div>
            </div>
            <br>
            <div class="row">
              <div class="col-md-3"><label for="password">Password:</label></div>
              <div class="col-md-9"><input type="password" name="password" class="form-control" id="password" placeholder="Your password"></div>
            </div>
            <br>
            <div class="row">
              <div class="col-md-3"><label for="password_confirmation">Confirm Password:</label></div>
              <div class="col-md-9"><input type="password" name="password_confirmation" class="form-control" id="password_confirmation" placeholder="Confirm your password"></div>
            </div>
          </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="submit" class="btn btn-primary">Confirm Registration</button>
        
      </div>
      </form>
    </div>
  </div>
</div>

Route:

Route::post('/auth/register', ['uses'=>'Auth\AuthController@postRegister', 'as'=>'register']);

The modal window on which I want to redirect:

enter image description here

Thanks.



via S M Iftakhairul

Advertisement