I want to return to my modal dialog editing form to show validation errors, but using Redirect::backI'm just on an HTML page without a modal window.
I use BootstrapDialog to load my route attendee.editinto a modal dialog that issues an edit form.
HTML
<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>
JQuery call for BootstrapDialog
$(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();
}
}]
});
});
});
controller
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');
}
After I edit the form, I want to return to the modal window to display validation errors, but I just end up on the HTML page without a dialog. How to redirect back to the modal window?
UPDATE
added idto controller return
return Redirect::back()->withErrors($validator)->withInput()->with('id', $id);
Added jQuery
@if(!empty(Session::get('id')))
$(document).ready(function(){
url = "{{ URL('attendee') . '/' . Session::get('id'). '/edit' }}";
BootstrapDialog.show({
title: $(this).data('title'),
message: $('<div></div>').load(url),
buttons: [{
label: 'Update',
action: function(dialogRef) {
$('form').submit();
}
}]
});
});
@endif
, , , . , , , .