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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22272841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 09:09:11  来源:igfitidea点击:

Return Input::except() multiple inputs in Laravel 4

phpvalidationlaravellaravel-4

提问by Obama

I am working with Laravel 4,

我正在使用 Laravel 4,

I am validating a form with the validator :

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

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

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

When it fails :

当它失败时:

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
        } 

How can i return inputs excepting multiple inputs, not only the password ?

我如何返回除多个输入之外的输入,而不仅仅是密码?

I've tried Input::except('password','avatar');but it's not working.

我试过了,Input::except('password','avatar');但它不起作用。

Any help would be greatly appreciated!

任何帮助将不胜感激!

采纳答案by Obama

Actually, i found that i forget to put the Input::old('')to repopulate the input,

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

So the solution is exaclty what i've tried Input::except('password','avatar');

所以解决方案就是我尝试过的 Input::except('password','avatar');

回答by Khean

Try

尝试

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