【问题标题】:Skip multiple input fields in Laravel 4在 Laravel 4 中跳过多个输入字段
【发布时间】:2015-04-03 08:51:34
【问题描述】:

我有几个array 类型的字段,我想通过使用Input::except() 来避免这些字段。我该怎么做? HTML 如下:

<tr>
   <td>
       {{ Form::input('text', 'batch_name[]', null, ['placeholder' =>'Enter batch name']) }}
   </td>
   <td>
       {{ Form::input('date', 'availability_date[]', null) }}
   </td>
   <td>
       <a class="add" title="Add Row" href="#"><img src="{{URL::to('public/assets/images/plus.png')}}" alt=""/></a>
   </td>
</tr>

以下不起作用并给出错误:

htmlentities() 期望参数 1 是字符串,给定数组

Validator::make(Input::except('_token','batch_name[]','availability_date[]'), $rules);

【问题讨论】:

  • 试试Validator::make(Input::except('_token','batch_name','availability_date'), $rules); - 可以正常工作吗?
  • 只要把batch_name$rules中去掉,就不会被验证了。
  • @TheShiftExchange 不,不是。

标签: php validation laravel-4 input-field


【解决方案1】:

好的,我发现了问题。我在重定向中使用了以下内容:

return Redirect::to('admin/item/add')
                ->withErrors($validator)
                ->withInput(Input::except('_token'));

通过将其更改为以下工作:

return Redirect::to('admin/item/add')
                ->withErrors($validator)
                ->withInput(Input::except('_token','batch_name','availability_date'));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-24
    • 1970-01-01
    • 2014-05-19
    • 2014-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多