The problem is that the drop-down menu is not selected by default
There is a drop-down menu for select in the interface that modifies the content of the article:
(
already on the head of the form, the corresponding $article model is bound)
{!! Form::label('tag_list', 'Tags:') !!} {!! Form::select('tag_list[]', $tags, null, ['class' => 'form-control', 'multiple']) !!}
Also, the method of setting the collector in the article model:
public function getTagListAttribute () { return $this->tags->lists('id'); }
In the interface, each option in select has the correct value, but it is not selected.
Then want to ask again, use laravel form of the Select, is not automatically go to correspond to gettaglistattribute this method?? The corresponding relationship is associated with the Name property of the select tag?
Add:
The picker can get the corresponding article tag ID on the article List page.
When editing an article, the other words of the article Geru (title, content) have corresponding content, model model binding is no problem
Reply content:
The problem is that the drop-down menu is not selected by default
There is a drop-down menu for select in the interface that modifies the content of the article:
( already in the form's head, the corresponding $article model is bound )
{!! Form::label('tag_list', 'Tags:') !!} {!! Form::select('tag_list[]', $tags, null, ['class' => 'form-control', 'multiple']) !!}
Also, the method of setting the collector in the article model:
public function getTagListAttribute () { return $this->tags->lists('id'); }
In the interface, each option in select has the correct value, but it is not selected.
Then want to ask again, use laravel form of the Select, is not automatically go to correspond to gettaglistattribute this method?? The corresponding relationship is associated with the Name property of the select tag?
Add:
The picker can get the corresponding article tag ID on the article List page.
When editing an article, the other words of the article Geru (title, content) have corresponding content, model model binding is no problem
You do this is possible, but also single-choice multi-selection of the general wording, the attributes can be one-to-many correspondence.
But you forget that the From header is also used from the output to the model form.
Laravel have any problems to communicate with me.
Theo, you add the->all () method to the back of the lists, the main point is to turn collection into an array here.
Lists in Laravel5 is the collection data structure, plus all after the array is taken out!
return $this->tags->lists (' id ')->all ();
has been said so detailed, can not solve and not to say.
Suppose you store the data variable called $data , then the name of the select and $data inside the key value to correspond, that $data is to store the tag key value called tag_list , should be so ~
If the key value is tag_id , change it to{!! Form::select('tag_id[]', $tags, null, ['class' => 'form-control', 'multiple']) !!}
You've been learning your video for help before @JellyBool.