laravel - selected value tag of Form::model doesn't bind property from Model -


i'm learning laravel , have issue when trying bind property of model selected values of select tag. tried leave 3rd parameter null because believe form model binding automatically take care of doesn't work. here tried:

   {{$article->tag_list}} // show [1,3]      //it doesn't work     {!! form::select('tag_list[]', $tags, null , ['class' => 'form-control', 'multiple'] ) !!}     -------------      //it doesn't work     {!! form::select('tag_list[]', $tags, $article->tag_list  , ['class' => 'form-control', 'multiple'] ) !!}     -----------      //it works     {!! form::select('tag_list[]', $tags, [1,3] , ['class' => 'form-control', 'multiple'] ) !!} 

in model have gettaglistattribute() works fine.

public function gettaglistattribute(){     return $this->tags->lists('id'); } 

with text input, form works fine. btw, i'm using 5.2.1 version. missing here ?

i found missing piece. select function expects array gettaglistattribute() return collection object.

public function gettaglistattribute(){   return $this->tags->lists('id')->all(); } or can public function gettaglistattribute(){   return $this->tags->lists('id')->toarray(); } 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -