jeudi 1 mars 2018

Input::old Laravel by dynamic field

Hi there i have a Problem, i have an dynamic field and i can't get the old value because i added this dynamic field with jquery. After validation the i don't have the fields.

Take a look in my Jquery codes :

 var fielddd = 1;
    $(document).on('click', '.btn.add-field', function() {
      fielddd++;
      $('#newfield').append('<textarea class="from-control" name="somename[]" id="field_' + field + '"></textarea>' + '<button class="btn add-field">add</button>' + '<textarea class="from-control" name="somename2[]" id="field_' + field + '"></textarea>');
    });

And HTML Code:

     <div class="row">
         <div class=""
          <textarea class="from-control"  name="somename[]" id="field"> 
        </textarea>
{!! $errors->first('somename[]',:message) !!}
</div>

          <button class="btn add-field">add</button>
    <div class=""
          <textarea class="from-control" name="name[]" id="field"></textarea>
    {!! $errors->first('somename[]',:message) !!}
</div>
        </div>

        <div class="row" id="newfield">
          <!-- new textarea -->
        </div>

The question is. How can i get the same fiels with the same input after validation if for exmple some field is empty.If i press add field, and after that pressing the button submit the laravel check if the field is empty and if yes then he redirect to the same page and say to put some value inside the text area.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire