Good morning everyone
I'm trying to save a dynamic input and a dynamic select but I can not do it
This is my view of what I want to save
I can save them like this
$name = $request->title;
$description = $request->seldimen;
$count = count($name);
for($i = 1; $i < $count; $i++){
$objModel = new EstructuraFinal();
$objModel->nombre_estructuraf = $name[$i];
$objModel->id_indice = $indice;
$objModel->id_area = $area;
$objModel->id_departamento = $departamento;
$objModel->id_dimension = $description[$i];
$objModel->save();
}
but it only works for me the first time when my table is blank and then I get this error
check the value of my input and select and if you return values but you do not save it, the line of error that you check is this $objModel->nombre_estructuraf = $name[$i];
htlm of the form
@foreach($estructura as $estructura)
<tr id="formato{{$estructura->id_estructura}}">
<th scope="row">{{$estructura->id_estructura}}</th>
<td><input type="text" class="form-control" name="title[{{$estructura->id_estructura}}]" value="{{$estructura->nombre_estructura}}"></td>
<td>
<select class="form-control" name="seldimen[{{$estructura->id_estructura}}]">
<option selected disabled>Selecciona una opción</option>
@foreach($dimensiones as $dimen)
<option value="{{$dimen->id_dimension}}">{{$dimen->nombre_dimension}}</option>
@endforeach
</select>
</td>
<td>
<button class="btn btn-danger btn-delete delete-producto" value="{{$estructura->id_estructura}}">Eliminar</button>
</td>
</tr>
@endforeach
I hope you can help me thanks