普通网友 2016-09-30 23:50
浏览 50

无法从Laravel 5.3的注册表中获取数组

I'm using Laravel 5.3 auth:make registration form, I have a multiple select in my form, which returns the count of the selected rows instead of array with the values.

Thats what coming back when I dd($data):

 array:10 [▼
      "_token" => "mBTBYC4yHsI0Ph1Hmj7p6MSstOCRM3cDkCoSZH4b"
      "first_name" => "User"
      "last_name" => "Family"
      "class" => "Software Engineer"
      "year" => "0"
      "tags" => "1" -> that should be an array.
      "phone" => "55555555"
      "email" => "test@test.com"
      "password" => "123123"
      "password_confirmation" => "123123"
    ]

The are I would like to fix looks like this in the html:

<div class="form-group{{ $errors->has('tags') ? ' has-error' : '' }}">
    {!! Form::select('tags[]', $tags , null , ['class' => 'form-control' , 'multiple' , 'id'=>'tags' , 'name' => 'tags']) !!}
    @if ($errors->has('tags'))
        <span class="help-block">
            <strong>{{ $errors->first('tags') }}</strong>
        </span>
    @endif
</div>
  • 写回答

1条回答 默认 最新

  • dsi37923 2016-10-01 01:38
    关注

    i think the problem is that you are not give them ("tags[]") a key to save multiple data into the array. this is what I handle the tags array with a checkbox {!! Form::checkbox('tag_id[]',$tag->id, null, ['class'=>'tag_id']) !!} check the second argument, I load the value into Id inside of the tag_id[] array.

    评论

报告相同问题?

悬赏问题

  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了