@herminia_bruen
To update dynamic input fields in Laravel, you can follow these steps:
Here is a basic example of how you can update dynamic input fields in Laravel:
1 2 3 4 5 6 |
<form action="{{ route('update.fields') }}" method="POST"> @csrf <input type="text" name="name[]"> <button type="button" id="add-field">Add field</button> <button type="submit">Submit</button> </form> |
1 2 3 |
$('#add-field').click(function() { $('form').append('<input type="text" name="name[]">'); }); |
1 2 3 4 5 6 7 8 |
public function updateFields(Request $request) { foreach($request->name as $name) { // Update or create a model with the input data ModelName::updateOrCreate(['name' => $name]); } return redirect()->back()->with('success', 'Fields updated successfully'); } |
1
|
Route::post('/update-fields', 'ControllerName@updateFields')->name('update.fields'); |
This is just a basic example and you can customize it to fit your specific requirements.