I'm new to Laravel and Vue and need help implementing Vue-Multiselect.
I don't know how to pass the actual options to the select.
My vue file:
<template>
<div class="dropdown">
<multiselect
:selected.sync="selected"
:show-labels="false"
:options="options"
:placeholder="placeholder"
:searchable="false"
:allow-empty="false"
:multiple="false"
key="name"
label="name"
></multiselect>
<label v-show="showLabel" for="multiselect"><span></span>Language</label>
</div>
</template>
<script>
import { Multiselect } from 'vue-multiselect';
export default {
components: { Multiselect },
props: {
options: {},
placeholder: {
default: 'Select one'
},
showLabel: {
type: Boolean,
default: true
},
selected: ''
}
};
</script>
My blade file:
<div class="form-group">
<drop-down
:options=""
:selected.sync="selected"
:show-label="false"
></drop-down>
</div>
In my controller method I tried a few things:
1.
public function edit($id)
{
....
$members_list = Member::orderBy('member_first_name')->pluck('member_first_name', member_id');
return view('businesses.edit', compact('members_list'));
}
I got this error: [Vue warn]: Invalid prop: type check failed for prop "options". Expected Array, got Object. (found in component: )
-
I tried:
$members = Member::orderBy('member_first_name')->pluck('member_first_name', member_id'); $members_list = $members->all(); return view('businesses.edit', compact('members_list')); $members_list = $member->all();
I got this error: htmlspecialchars() expects parameter 1 to be string, array given (View: C:\wamp\www\ccf.local\resources\views\businesses\edit.blade.php)
So I need help with 2 things:
- How to send the $members_list as the options
-
How can I combine the member_first_name and member_last_name fields so I can get options like this:
option value="member_id" option text = member_first_name member_last_name
Thank you
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire