【发布时间】:2014-07-18 21:50:24
【问题描述】:
在我的刀片文件中
<form id=""
class="form-horizontal"
accept-charset="UTF-8"
action="/apply/post/{{$content->vacancy->Id}}"
method="POST">
还有我的routes.php:
Route::get('/apply/post/{ref}', function($ref) {
// 1. Define some rules and validate...
$rules = array('forename' => array('required'), 'email' => array('required'), 'surname' => array('required'), 'address1' => array('required') );
$validator = Validator::make(Input::all(), $rules, array('required' => 'The :attribute is required.') );
if( $validator->fails() ) {
$messages = $validator->messages();
return Redirect::to("http://example.co.uk/apply/{$ref}")->withInput()->withErrors($messages);
} else {
// do stuff with Input::all()
}
}
无论我尝试Redirect::to(),即Redirect::back(),在提交表单后,我最终都会被重定向回http://example.co.uk/apply/post/234,这导致我进入未定义的路线和错误页面。
如果用户验证失败,我真的希望他们重定向回http://example.co.uk/apply/234,并显示错误/消息。这样他们就可以重新尝试输入正确的信息,最终将表单提交给http://example.co.uk/apply/post/234 说。
别问,我继承了代码,我的 Laravel 是初学者,但是使用框架可以吗?
【问题讨论】:
标签: laravel