一次提交多条记录 - Laravel 5.2

时间:2016-04-30 16:30:16

标签: php database laravel

我在每一行都有一个包含输入字段的表,但我想一次提交所有输入,而不是逐一提交。我应该把提交按钮放在哪里?就像我一样,我只提交表格中的最后一行。

<table class="table table-responsive table-striped" id="admin-table">
    <thead>
    <tr>
        <th>Клас:</th>
        <th>N:</th>
        <th>Име:</th>
        <th>Предмет:</th>
        <th>Оценка:</th>
        <th>Тип на оценката:</th>

    </tr>
    </thead>
    <tbody>
    @foreach($students as $student)
        @foreach($class as $classes)
          @foreach($sub as $subject)
        <tr>
            {!! Form::open(['action' => 'Educator\AccountController@markStudent', $subject, 'class' => 'form-horizontal']) !!}
            <td>
                {{$classes->name}}
            </td>
            <td>
                {!! Form::text('student_id', $student->id) !!}
            </td>
            <td>
                {{$student->full_name}}
            </td>
            <td>
                {!! Form::text('subject_id', $subject->id) !!}
            </td>
            <td>
                {!! Form::text('mark',null, ['class'=>'form-control col-md-2']) !!}
            </td>
            <td>
                {!! Form::select('markType', $markType, null, ['class'=>'form-control']) !!}
            </td>
        </tr>

            @endforeach
          @endforeach
        @endforeach
    <div align="center">
        <a href="{{url('educator/class-subject')}}"><button type="button" class="btn btn-default">Назад</button></a>
        {!! Form::submit('Запиши', ['class' => 'btn btn-default']) !!}

    </div>
    {!! Form::close() !!}
    </tbody>
</table>

2 个答案:

答案 0 :(得分:2)

首先在所有foreach之外移动 return RedirectToAction(string.Format("login/{0}?post_login_redirect_url=/Home/LoginCallBack", provider), ".auth");

然后你必须更改数组的所有输入(使用Form::open itteration),所以你的循环将如下所示:

$i

答案 1 :(得分:0)

在tbody标签之后移动您的{{Form :: open}}在foreach之外。它应该工作。