doufei2194 2016-01-19 07:36
浏览 110
已采纳

Laravel 5.2在@foreach中形成

I try to put a form inside a foreach loop. The code is:

@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

Problem are that form tag close immediately:

<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>

Someone can help me?

  • 写回答

1条回答 默认 最新

  • dougua2309 2016-01-19 13:58
    关注

    You can't put form inner table. Try this.

       <form>
         @foreach()
           <table> .... </table>
         @endforeach
      </form>
    

    Note: Browsers manipulate html tags.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题