Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate Multi-Select on Edit #114

Open
kjgenevieve opened this issue Jan 21, 2021 · 2 comments
Open

Populate Multi-Select on Edit #114

kjgenevieve opened this issue Jan 21, 2021 · 2 comments

Comments

@kjgenevieve
Copy link

Hello,

I haven't been able to get the formerly selected items to populate my form on edit. It appears blank, just as it would in a new form. If I save without touching the multi-select, the previous choices are sustained.

My edit form code is:

    <%= form.select :tag_list,
        Tag.all.map { |t| [t.name, t.id] },
            { include_blank: false},
            { class: "chosen-select", multiple: true }
    %>
@kjgenevieve
Copy link
Author

Updated my code to what's below does show me the selected items, but I cannot get the Chosen-style appearance.
Screen Shot 2021-01-21 at 10 23 54 AM

                                <%= form.collection_select(
                                    :tag_ids, 
                                    Tag.all, 
                                    :id, 
                                    :name, 
                                    {}, 
                                    {multiple: true, class: "chosen-select"})
                                %>

@bjer
Copy link

bjer commented Jul 7, 2022

A bit late to the party...
Did you require chosen-jquery in application.js / , chosen in application.css and did you have
<%= javascript_include_tag 'application' %> in your app layout ?
Works for me using rails 6.x

@sandritis2 sandritis2 mentioned this issue Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants