platanus / activeadmin_addons

Extends ActiveAdmin to enable a set of great optional UX improving add-ons
MIT License
752 stars 282 forks source link

[BUG] #495

Open antarr opened 4 months ago

antarr commented 4 months ago

Describe the bug When using as: :tags, the current value is not selected.

Expected behavior When I go to edit a record the current values for in my list should be render.

Screenshots

show(with current values)

image

edit(values missing)

image

Code

  controller do
    def update
      committee = LegiscanModel::Committee.friendly.find(params[:id])
      committee.people = LegiscanModel::Politician.where(people_id: params[:legiscan_model_committee][:people_ids])
      committee.save
      super
    end
  end

  permit_params :name, :state_id, :slug, :people_ids, :committee_id
  form do |f|
    f.inputs do
      f.input :name, input_html: { disabled: true }
      f.input :slug, input_html: { disabled: true }
      f.input :people_ids,
        label: 'Members',
        as: :tags,
        collection: LegiscanModel::Politician.where(state_id: f.object.state_id).order(:last_name),
        fields: [:full_name]
    end
    f.actions
  end