1
I need to remove the values that from the first input are empty.
$count = count($request->item);
for($i=0; $i < $count; $i++) {
if ($request->item[$i] === null) {
unset($request->item[$i]);
unset($request->descricao[$i]);
unset($request->quantidade[$i]);
unset($request->valor_unitario[$i]);
unset($request->desconto[$i]);
}
}
dd($request->item);
is returning the following error:
"Indirect modification of overloaded Property App Http Requests Orcamentosrequest::$item has no Effect"
<tr>
<td><input id="item" name="item[]" type="text" class="form-control form-control-sm" aria-required="true" aria-invalid="false" value="{{ old('item.0') }}"></td>
<td><input id="descricao" name="descricao[]" type="text" class="form-control form-control-sm" aria-required="true" aria-invalid="false" value="{{ old('descricao.0') }}"></td>
<td><input id="quantidade" name="quantidade[]" type="text" class="form-control form-control-sm" aria-required="true" aria-invalid="false" value="{{ old('quantidade.0') }}"></td>
<td><input id="valor_unitario" name="valor_unitario[]" type="text" class="form-control form-control-sm" aria-required="true" aria-invalid="false" value="{{ old('valor_unitario.0') }}"></td>
<td><input id="desconto" name="desconto[]" type="text" class="form-control form-control-sm" aria-required="true" aria-invalid="false" value="{{ old('desconto.0') }}"></td>
<td><a onclick="RemoveTableRow(this)" id="delete" class="delete"><i class="fa fa-trash"></i></a></td>
</tr>
I’m getting the data all right, on request, only from the problem when using UNSET
Has the HTML part?
– novic
posted.. but it’s working.. only gives this error when I put the unset to remove
– MichaelCosta