Я пытаюсь поместить форму в цикл foreach. Код является:
@foreach( $document_rows as $row )
<?php
$idx = $row->id;
$product = Product::find( $row->product_id );
$vat = Vat::find( $row->vat_id );
$tot_riga = floatval($row->price) * intval($row->product_quantity);
?>
{!! Form::open([
'method' => 'PUT',
'route' => [ 'document.row.update', $document->id, $row->id ],
'class' => 'form-horizontal',
]) !!}
<tr class="document_row">
<td
id="field_id-{{ $idx }}"readonly="true"data-field="id"data-id="{{ $idx }}">
{{ $idx }}
</td>
<td
class="field"id="field_name-{{$idx}}"data-field="name"data-id="{{ $idx }}">
{{ $row->product_name }}
</td>
<td
class="field"id="field_um-{{$idx}}"data-field="um"data-id="{{ $idx }}">
{{ $row->product_um }}
</td>
<td
class="field"id="field_quantity-{{ $idx }}"data-field="quantity"data-id="{{ $idx }}">
{{ $row->product_quantity }}
</td>
<td
class="field"id="field_price-{{ $idx }}"data-field="price"data-id="{{ $idx }}">
{{ $row->price }}
</td>
<td
class="field"id="field_vat-{{ $idx }}"data-field="vat"data-id="{{ $idx }}">
{{ $vat->name }}
</td>
<td
class="field"id="field_price_inc_vat-{{ $idx }}"data-field="price_inc_vat"data-id="{{ $idx }}">
{{ $row->price_inc_vat }}
</td>
<td
id="field_tot_riga-{{ $idx }}"readonly="true"data-field="tot_riga"data-id="{{ $idx }}">
{{ $tot_riga }}
</td>
</tr>
{!! Form::close() !!}
@endforeach
Проблема в том, что тег формы закрывается немедленно:
<form method="POST" action="http://localhost:8888/site/public/document/1/row/update/1" accept-charset="UTF-8" class="form-horizontal"></form><input name="_method" type="hidden" value="PUT"><input name="_token" type="hidden" value="62PHHV4cnYmVOVQkkV43UCWdTkbE3tpo0OIUxuCx">
<tr class="document_row">
<td id="field_id-1" readonly="true" data-field="id" data-id="1" tabindex="1">1</td>
<td class="field" id="field_name-1" data-field="name" data-id="1" tabindex="1"></td>
<td class="field" id="field_um-1" data-field="um" data-id="1" tabindex="1">nr</td>
<td class="field" id="field_quantity-1" data-field="quantity" data-id="1" tabindex="1">100</td>
<td class="field" id="field_price-1" data-field="price" data-id="1" tabindex="1">13</td>
<td class="field" id="field_vat-1" data-field="vat" data-id="1" tabindex="1">Iva 22%</td>
<td class="field" id="field_price_inc_vat-1" data-field="price_inc_vat" data-id="1" tabindex="1">15</td>
<td id="field_tot_riga-1" readonly="true" data-field="tot_riga" data-id="1" tabindex="1">1300</td>
</tr>
Кто-то может мне помочь?
Вы не можете положить форму внутренней таблицы.
Попробуй это.
<form>
@foreach()
<table> .... </table>
@endforeach
</form>
Заметка: Браузеры манипулируют HTML-тегами.
Других решений пока нет …