0

検証後、モーダルで Session/messagebag $error データを失いました。これは、編集フォームの出席者/編集をリンクからモーダル本文にロードしているため、モーダルを呼び出すページに $error データが送信され、モーダル本文は呼び出されないためだと思います。モーダルをオフにして、ページの参加者/編集を直接ロードすると、検証エラーが正常に表示されます。モーダル本文に表示される編集フォームに $error 変数を渡す方法はありますか?

現在の実装では、モーダルをリロードしてポップアウト/インする必要があるように思われるため、AJAX を使用することをお勧めします。しかし、 $error messagebag オブジェクトを編集フォーム/セッションデータからモーダルに転送する方法もわかりません。$error メッセージバッグに入力するために、このメソッドstackoverflow.com/questions/25103743/laravel-4-validation-in-bootstrap-modalを使用する方法があるかどうか疑問に思っています。

メインビュー

    <td>{{link_to_route('attendee.edit','',array($attendee->id), array(
            'class'=>'edit-attendee btn btn-info btn-xs glyphicon glyphicon-pencil',
            'data-title' => 'Edit Attendee'))}} 
    </td>

BootstrapDialog への JQuery 呼び出し

$(document).ready(function(){
    $('.btn.edit-attendee').click(function(e){
        e.preventDefault();
        url = $(this).attr('href');
        BootstrapDialog.show({
            title: $(this).data('title'),
            message: $('<div></div>').load(url),
            buttons: [{
                label: 'Update',
                action: function(dialogRef) {
                    $('form').submit();
                }
            }]
        });
    });
});

出席者/編集ビュー

{{ Form::model($attendee, array('class'=>'form-horizontal', 'method' => 'PATCH', 'route' => array('attendee.update', $attendee->id))) }}
        <div class="form-group {{{ $errors->has('first_name') ? 'has-error' : '' }}}">
            <label class="col-xs-3 control-label", for="first_name">First Name</label>
            <div class="col-xs-9">
                {{ Form::text('first_name', null , array('class' => 'form-control')) }}
            </div>
          {{ $errors->first('first_name', '<span class="help-inline">:message</span>')}}
        </div>

      <div class="form-group {{{ $errors->has('special_care') ? 'has-error' : '' }}}">
            <label class="col-xs-3 control-label", for="special_care">Special Care</label>
            <div class="col-xs-9">
                {{ Form::text('special_care', null , array('class' => 'form-control')) }}
            </div>
            {{ $errors->first('age', '<span class="help-inline">:message</span>')}}
        </div>
        {{Form::submit()}}
{{ Form::close() }}

コントローラ

    public function update($id)
    {
        $attendee = Attendee::findOrFail($id);



  $validator = Validator::make($data = Input::all(), Attendee::$rules);

    if ($validator->fails())
    {
        return Redirect::back()->withErrors($validator)->withInput();
    }

    $attendee->update($data);

    return Redirect::route('attendees.index');
}

フォームを編集した後、モーダル ウィンドウに戻って検証エラーを表示したいのですが、$errors がモーダルに渡されません。

4

1 に答える 1