Skip to content

Multiple Select not showing all initially selected options #6

@bkubic

Description

@bkubic

I have a multiple select box that works as expected to select and save multiple options. However, when I reload the form, only the first selected option shows up in the select2 box, even though all the previously selected relationships are saved in the database.

This only happens when using AJAX - when I provide a collection instead the box works as expected.

ActiveAdmin.register Offer do
  form do |f|
    f.input :buyers, as: :searchable_select, ajax: true, multiple: true
  end
end
ActiveAdmin.register Buyer do
  searchable_select_options(scope: Buyer.all.order(last_name: :asc),
                             text_attribute: :name_email,
                             filter: lambda{|term, scope| scope.ransack(first_name_or_last_name_or_email_cont: term.downcase, phone_number_cont: (term.gsub(/\D/, '').presence || "XXX"), m: 'or' ).result})
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions