【问题标题】:Return Input::except() multiple inputs in Laravel 4在 Laravel 4 中返回 Input::except() 多个输入
【发布时间】:2014-04-11 22:38:17
【问题描述】:

我正在使用 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');,但它不起作用。

任何帮助将不胜感激!

【问题讨论】:

    标签: php validation laravel laravel-4


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      试试

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

      【讨论】:

      • 我使用的是 laravel 4.2。请查看第 253 行中的 \vendor\laravel\framework\src\Illuminate\Http\Request.php 函数 except($keys) @param $keys is array
      猜你喜欢
      • 1970-01-01
      • 2022-01-27
      • 1970-01-01
      • 1970-01-01
      • 2013-06-28
      • 2014-11-09
      • 1970-01-01
      • 1970-01-01
      • 2014-06-03
      相关资源
      最近更新 更多