I have a problem with multiple select in laravel using illuminate html, I want to pre-select items, it works when I put them manuelly with an array like this :
{!! Form::select('tags_list[]', $tags, [2, 3], ['class' => 'form-control', 'multiple' => true]) !!}
But when I use a model to put the list, like this :
{!! Form::select('tags_list[]', $tags, $post->tags_list, ['class' => 'form-control', 'multiple' => true]) !!}
It doesn't work and I checked the list is returned correctly, here is the result of :
dd($post->tags_list);
Collection {#273 ▼
#items: array:2 [▼
0 => 1
1 => 2
]
}
And here is the method that return the tags_list
public function getTagsListAttribute()
{
return $this->tags->lists('id');
}
I am new in Laravel framework, can anyone help me with this issue, thanks in advance
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire