MattB
4 months ago
48
18
Laravel

Issue submitting form data from bootstrap 4 modal

Posted 4 months ago by MattB

I cannot get data to submit from a modal in laravel. When I use the below code and hit the 'add user' button, the modal just closes and doesn't seem to call the @store method in my controller. Data doesn't get submitted to the db

<div class="modal fade" id="addNew" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">New User</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        {!! Form::open(['method' =>'POST', 'action'=> '[email protected]', 'files'=>true, 'enctype'=>'multipart/form-data']) !!}
        <div class="form-group {{$errors->has('firstName') ? 'has-error' : ''}}">
          {!! Form::label('firstName', 'First Name:') !!}
          {!! Form::text('firstName', null, ['class'=>'form-control', 'rows' => 3])!!}
          @if($errors->has('firstName'))
            {{$errors->first('firstName')}}
          @endif
        </div>
{{--most form data removed for simplicity--}}
        <div class="form-group">
          {!! Form::submit('Add user', ['class'=>'btn btn-primary']) !!}
        </div>
        {!! Form::close() !!}
      </div>      
    </div>
  </div>
</div>

Please sign in or create an account to participate in this conversation.