How to open the modal bootstrap form after a validation error Laravel 5.4

1

I have a modal bootstrap contact form. I have the validations where they are validating correctly. Now my question is: How do I when not to pass the validation it return the message in modal with it open. When it validates and does not pass validation it does not open the modal. So the customer will never know that the form was sent How is my call in the modal: I have a View where I have the modal.blade.php in my index.blade.php I give an include in it and in my button where it activates the modal like this:

<div class="row">
  <div class="col-md-2 col-md-offset-3">
      <button type="button" data-toggle="modal"  
        data-target="#product_view" class="btn btn-default btn-lg">Clique aqui.</button>
  </div>
</div>

This butane calls my modal. How do I call this modal in the controller?

asked by anonymous 27.08.2017 / 01:23

1 answer

2

Well, sorry for my lack of attention, but really I do not have any skills in JS. So I repairing the code, I saw that it returns a session with an Errors variable. So I simply gave an if checking whether this session variable even existed. See:

@if(Session::has('errors'))
   e aqui dentro eu chamei o meu js.
@endif

As I said because I do not know much about js, I know that the first page will be read after the javascript is executed. So soon I did:

$(document).read(funciona(){
    alert('Ops!! Teve erros no seu formulário. Vamos abrir novamente para que você possa corrigir. ;) ');
    $('#product_view').modal('show');
 });

And so solving my problem.

    
27.08.2017 / 03:04