title: keep data form dynamically in laravel after submit if have field fail
body: <p>how to keep all data in form dynamically in Laravel 7 after submitting and request is failing. the all form Created Dynamically after click (button  Add more ) is deleted only keep the first form
  and lot all  old data
  My questions.</p>
  <p>1- how to keep all form dynamically created</p>
  <p>2 - how to keep  all data</p>
  <p>The Blade Form</p>
  <pre><code>    &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Add/remove multiple input fields dynamically&lt;/title&gt;
      &lt;link rel=&quot;stylesheet&quot; href=&quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css&quot; /&gt;  
      &lt;script src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js&quot;&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    
  &lt;div class=&quot;container&quot;&gt;
      &lt;h2 align=&quot;center&quot;&gt; &lt;/h2&gt; 
      &lt;form action=&quot;{{ route('addmorePost') }}&quot; method=&quot;POST&quot;&gt;
          @csrf
          @if ($errors-&gt;any())
              &lt;div class=&quot;alert alert-danger&quot;&gt;
                  &lt;ul&gt;
                      @foreach ($errors-&gt;all() as $error)
                          &lt;li&gt;{{ $error }}&lt;/li&gt;
                      @endforeach
                  &lt;/ul&gt;
              &lt;/div&gt;
          @endif
          @if (Session::has('success'))
              &lt;div class=&quot;alert alert-success text-center&quot;&gt;
                  &lt;a href=&quot;#&quot; class=&quot;close&quot; data-dismiss=&quot;alert&quot; aria-label=&quot;close&quot;&gt;×&lt;/a&gt;
                  &lt;p&gt;{{ Session::get('success') }}&lt;/p&gt;
              &lt;/div&gt;
          @endif
          &lt;table class=&quot;table table-bordered&quot; id=&quot;dynamicTable&quot;&gt;  
              &lt;tr&gt;
                  &lt;th&gt;Name&lt;/th&gt;
                  &lt;th&gt;Qty&lt;/th&gt;
                  &lt;th&gt;Price&lt;/th&gt;
                  &lt;th&gt;Action&lt;/th&gt;
              &lt;/tr&gt;
              &lt;tr&gt;  
                  &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;addmore[0][name]&quot; placeholder=&quot;Enter your Name&quot; class=&quot;form-control&quot; /&gt;&lt;/td&gt;  
                  &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;addmore[0][qty]&quot; placeholder=&quot;Enter your Qty&quot; class=&quot;form-control&quot; /&gt;&lt;/td&gt;  
                &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;addmore[0][price]&quot; placeholder=&quot;Enter your Price&quot; class=&quot;form-control&quot; /&gt;&lt;/td&gt;  
                  &lt;td&gt;&lt;button type=&quot;button&quot; name=&quot;add&quot; id=&quot;add&quot; class=&quot;btn btn-success&quot;&gt;Add More&lt;/button&gt;&lt;/td&gt;  
              &lt;/tr&gt;  
          &lt;/table&gt;  &lt;button type=&quot;submit&quot; class=&quot;btn btn-success&quot;&gt;Save&lt;/button&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;   
      var i = 0;      
      $(&quot;#add&quot;).click(function(){  
          ++i;  
          $(&quot;#dynamicTable&quot;).append('&lt;tr&gt;&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;addmore['+i+'][name]&quot; placeholder=&quot;Enter your Name&quot; class=&quot;form-control&quot; /&gt;&lt;/td&gt;&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;addmore['+i+'][qty]&quot; placeholder=&quot;Enter your Qty&quot; class=&quot;form-control&quot; /&gt;&lt;/td&gt;&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;addmore['+i+'][price]&quot; placeholder=&quot;Enter your Price&quot; class=&quot;form-control&quot; /&gt;&lt;/td&gt;&lt;td&gt;&lt;button type=&quot;button&quot; class=&quot;btn btn-danger remove-tr&quot;&gt;Remove&lt;/button&gt;&lt;/td&gt;&lt;/tr&gt;');
      }); 
      $(document).on('click', '.remove-tr', function(){  
           $(this).parents('tr').remove();
      });    
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>The Controller</p>
  <pre><code>&lt;?php
  
     
  
  namespace App\Http\Controllers;
  
      
  
  use Illuminate\Http\Request;
  
  use App\ProductStock;
  
     
  
  class ProductAddMoreController extends Controller
  
  {
  
      /**
  
       * Display a listing of the resource.
  
       *
  
       * @return \Illuminate\Http\Response
  
       */
  
      public function addMore()
  
      {
  
          return view(&quot;addMore&quot;);
  
      }
  
      
  
      /**
  
       * Display a listing of the resource.
  
       *
  
       * @return \Illuminate\Http\Response
  
       */
  
      public function addMorePost(Request $request)
  
      {
  
          $request-&gt;validate([
  
              'addmore.*.name' =&gt; 'required',
  
              'addmore.*.qty' =&gt; 'required',
  
              'addmore.*.price' =&gt; 'required',
  
          ]);
  
      
  
          foreach ($request-&gt;addmore as $key =&gt; $value) {
  
              ProductStock::create($value);
  
          }
  
      
  
          return back()-&gt;with('success', 'Record Created Successfully.');
  
      }
  
  }
  </code></pre>