title: Specifying forms in laravel
body: <p>I have data which will append to blade view <code>codes below</code> and each of them is warped into a form, the issue is data that will send to back-end always comes from first form (somehow other forms data will be ignored).</p>
  
  <p><strong>How my forms look like:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/hO3iO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hO3iO.png" alt="one"></a></p>
  
  <p><strong>Sending data from first form</strong> <code>ID = 7</code></p>
  
  <p><a href="https://i.stack.imgur.com/OQPof.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OQPof.png" alt="two"></a></p>
  
  <p><strong>Sending data from second form</strong> <code>Still ID 7</code></p>
  
  <p><a href="https://i.stack.imgur.com/6LfE9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6LfE9.png" alt="three"></a></p>
  
  <h1>Code</h1>
  
  <pre><code>&lt;script defer&gt;
    $(document).ready(function() {
     $("body").on("click", ".savedynspecto", function(e){
        var form = $(this).closest('form');
        var id = form.find('input[name="product_id"]').val();
        // e.preventDefault();
        $.ajax({
          type: "post",
          url: '{{ url('admin/spacssendto') }}',
          data: {
            '_token': $('input[name=_token]').val(),
            'product_id': id,
            'subspecifications': $(this).closest('form').find('select.subspecifications').val()
          },
          success: function (data) {
            alert('Specifications added successfully.');
          },
          error: function (data) {
            console.log('Error!');
          }
        });
      });
    });
  &lt;/script&gt;
  </code></pre>
  
  <p><code>Controller</code></p>
  
  <pre><code>public function spacssendto(Request $request) {
  
          $testingdata = $this-&gt;validate($request, array(
            'product_id' =&gt; 'required',
            'subspecifications' =&gt; 'required',
          ));
          $product = Product::find($request-&gt;product_id);
          $product-&gt;subspecifications()-&gt;sync($request-&gt;subspecifications, false);
  
          return response()-&gt;json($testingdata);
      }
  </code></pre>
  
  <p>HTML output of my forms</p>
  
  <pre><code>&lt;tr&gt;
  
    &lt;form method="POST" action="http://site.pp/admin/products/15/edit" accept-charset="UTF-8"&gt;
  
    &lt;/form&gt;
    &lt;input name="_token" value="DLrcOa0eOm90e4aaGSYp2uCeiuKtbGCT9fCOUP16" type="hidden"&gt;
  
    &lt;input name="product_id" id="product_id" value="15" type="hidden"&gt;
  
    &lt;td&gt;Graphic&lt;/td&gt;
  
    &lt;td&gt;
  
      &lt;select class="subspecifications form-control tagsselector" id="subspecifications" name="subspecifications[]" multiple="multiple"&gt;
  
        &lt;option value="7"&gt;Intel 920&lt;/option&gt;
  
      &lt;/select&gt;
  
    &lt;/td&gt;
  
    &lt;td class="text-center"&gt;
  
      &lt;button type="button" id="savedynspecto" class="savedynspecto btn btn-md btn-success"&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; Save&lt;/button&gt;
  
    &lt;/td&gt;
  
  &lt;/tr&gt;
  </code></pre>
  
  <p><strong>Note:</strong></p>
  
  <p>What makes me curious is why my form closed right after it opened!</p>
  
  <pre><code>&lt;tr&gt;
   &lt;form method="POST" action="http://site.pp/admin/products/15/edit" accept-charset="UTF-8"&gt;
  
    &lt;/form&gt;
  ...
  </code></pre>
  
  <p>here is how my row will append to blade</p>
  
  <pre><code>var my_row = $('&lt;tr&gt;');
  var my_html = '{{ Form::open() }}&lt;input name="product_id" id="product_id" type="hidden" value="{{$product-&gt;id}}"&gt;&lt;td&gt;'+value1.title+'&lt;/td&gt;';
  my_html += '&lt;td&gt;&lt;select class="subspecifications form-control tagsselector" id="subspecifications" name="subspecifications[]" multiple="multiple"&gt;'+helpers+'&lt;/select&gt;&lt;/td&gt;';
  my_html += '&lt;td class="text-center"&gt;&lt;button type="button" id="savedynspecto" class="savedynspecto btn btn-md btn-success"&gt;&lt;i class="fa fa-check"&gt;&lt;/i&gt; Save&lt;/button&gt;&lt;/td&gt;{{Form::close()}}&lt;/tr&gt;';
  my_row.html(my_html);
  $('#addcustomstr').append(my_row);
  </code></pre>
  
  <p>As you see my <code>{{ Form::open() }}</code> is before first <code>&lt;td&gt;</code> and <code>{{Form::close()}}</code> is right before <code>&lt;/tr&gt;</code> but why is closing right after it's open?</p>
  
  <p><strong>Any idea?</strong></p>