在Laravel 4中返回Input :: except()多个输入

时间:2014-03-08 17:48:54

标签: php validation laravel laravel-4

我正在使用Laravel 4,

我正在使用验证器验证表单:

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

失败时:

if ($validator->fails()) {
            return Redirect::to('register/test')
                            ->withErrors($validator)
                            ->withInput(Input::except('password')); // send back the input so that we can repopulate the form
        } 

除了多个输入外,我怎样才能返回输入,而不仅仅是密码?

我已经尝试了Input::except('password','avatar');,但它无效。

非常感谢任何帮助!

2 个答案:

答案 0 :(得分:8)

实际上,我发现我忘了让Input::old('')重新填充输入,

所以解决方案很简单,我试过Input::except('password','avatar');

答案 1 :(得分:3)

尝试

Input::except(array('password', 'avatar'));