Support the ongoing development of Laravel.io →
Requests Input
Last updated 2 years ago.
0

In this line

{!! Form::select('tag_list[]',$tags,null,['class'=>'form-control','multiple']) !!}

the third parameter of the select() method should contain the default value(s) of the select. You're passing null so there are no default values which will be selected automatically. Here you need to pass the result of your tag_list attribute so for example like this (not 100% sure if it's correct):

{!! Form::select('tag_list[]',$tags, $cat->tag_list ,['class'=>'form-control','multiple']) !!}
0

@ftiersch

But at 12'06 of the video, Jeff says it can be null, the form model binding will take care that. I am confused, don't know what is wrong.

0

@ftiersch

I have figured out the problems,

$this->tags->lists('id')

return a collection,

we need to cast it to array, so

$this->tags->lists('id')->toArray()

will work.

I think the newest laravel changed the returned value type.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

larameta larameta Joined 2 Aug 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.