vendredi 30 septembre 2016

Vue-Multiselect with Laravel 5.3

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: )

  1. 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:

  1. How to send the $members_list as the options
  2. 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



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2cGDQNt
via IFTTT

Aucun commentaire:

Enregistrer un commentaire