2

I am using Laravel 5 and I have some forms in one page. All is works except the last one. It is nothing happen, no error. I tried to put alert in the button. The alert showed, but the data won't saved.

<tr>
  <div>
    <form action="{{ url('AddComment') }}" method="POST">
      <div>
      <td>
        <textarea class="form-control edit" id="com_comment2" name="com_comment2" style="width:90%"  placeholder="Type a New Comment.." required=""></textarea>
        <input type="hidden" name="com_leads2" value="{{ $leads[0]->LED_CODE }}">
        <input type="hidden" name="_token" value="{{ csrf_token() }}"/>
        <button id ="af" class="btn btn-round btn-success">Submit</button>
      </td>
    </div>
    </form>
  </div>
</tr>
hendraspt
  • 879
  • 2
  • 15
  • 34

7 Answers7

0

You need to have one submit button to submit a form until you submit it using jquery.

<tr>
  <div>
    <form action="{{ url('AddComment') }}" method="POST">
      <div>
      <td>
        <textarea class="form-control edit" id="com_comment2" name="com_comment2" style="width:90%"  placeholder="Type a New Comment.." required=""></textarea>
        <input type="hidden" name="com_leads2" value="{{ $leads[0]->LED_CODE }}">
        <input type="submit" value="Submit">  // This is SUBMIT button.
      </td>
    </div>
    </form>
  </div>
</tr>

Or, If you want to keep the <button> as it is, then you should use jquery/JS function to submit it.

Himanshu Upadhyay
  • 6,220
  • 1
  • 13
  • 32
0

add button type too

<button id ="af" class="btn btn-round btn-success" type="submit">Submit</button>
Rp9
  • 1,855
  • 2
  • 18
  • 28
0

You are not sending CSRF token in the form. Please use CSRF token in your form.

{ csrf_field() }}

Then you need to use

<input type="submit"/>

for submitting form.If you want to use

<button/>

to sbumit form,then you have to submit your form using jquery. Your form should look like.

<form action="{{ url('AddComment') }}" method="POST">
  { csrf_field() }}
  <div>
    <td>
      <textarea class="form-control edit" id="com_comment2" name="com_comment2" style="width:90%"  placeholder="Type a New Comment.." required=""></textarea>
      <input type="hidden" name="com_leads2" value="{{ $leads[0]->LED_CODE }}">
      <input type="submit" value="Submit">
    </td>
  </div>
</form>
0

Check these points:

1. Add { csrf_field() }} into your form

2. Change button to input type submit (<input type="submit"/>)

3. Check your modal and find out if all fields are fillable.

4. Print your query and check what sql query has been created.
Jyoti mishra
  • 569
  • 4
  • 16
0

Add CSRF:

<input type="hidden" value="{{csrf_token()}}" name="_token" id="token">

OR

{!! csrf_field() !!}

Good luck

Jinandra Gupta
  • 496
  • 2
  • 6
0

Thank you for all the answer to helping me. I have tried it all but still nothing happen. But I looked at @JYoThI comment which said 'You can't place the form as a child element of table ,tbody, tr .' then I moved the form tags inside the <td> and the it is work !!

<td>
  <form action="{{ url('AddComment') }}" method="POST">
    <textarea class="form-control edit" id="com_comment2" name="com_comment2" style="width:90%"  placeholder="Type a New Comment.." required=""></textarea>
    <input type="hidden" name="com_leads2" value="{{ $leads[0]->LED_CODE }}">
    <input type="hidden" name="_token" value="{{ csrf_token() }}"/>
    <button id ="afjk" class="btn btn-round btn-success">Submit</button>
  </form>
</td>
hendraspt
  • 879
  • 2
  • 15
  • 34
0

Check #af on your JavaScript, maybe you put preventDefault() on it. Because if not, every posted answer should have solved your problem by now

Muabazalm
  • 356
  • 1
  • 10