Answer the question
In order to leave comments, you need to log in
How to make dynamic fields in laravel?
There is 1 field
<input name="hobby[]" >
<div>добавить хобби</div>
<button> </button>
<input name="hobby[]" >
<input name="hobby[]" >
<div>добавить хобби</div>
<button> </button>
"hobby.*" => 'required|string',
Answer the question
In order to leave comments, you need to log in
The previous values can be obtained by a function old()
in old('hobby')
you will have an array.
Here, display all the fields
@foreach(old('hobby') as $value)
<input name="hobby[]" value="{{ $value }}"
@endforech
@if ($errors->any())
@foreach ($errors->all() as $error)
<p>{{ $error }}</p>
@endforeach
@endif
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question