Skip to content

Use em-select to fill a hasMany #122

@flyrev

Description

@flyrev

Let's say that a user should choose his favorite artist, yet, we're not going to use the name but rather a reference to another artist.

    {{em-select
        label="Artist"
        property="artist"
        content=artists
        optionValuePath="id"
        optionLabelPath="name"
        prompt="Who's your favorite artist?"
    }}

So, we have
// models/artist.js
export default Model.extend({
name: attr('string')
})

// models/user.js
export default Model.extend({
artists: hasMany('artist', { embedded: 'always', async: true })
});

Now, if I pass store.findAll('artist') to the dropdown, and try to update it, we will get the following:
Assertion Failed: You must pass an array of records to set a hasMany relationship

How can I make it work if I want to update a relationship on an object instead of just a value? Preferably what I would want in this example is to either overwrite the list entirely by the selected dropdow, or append to it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions