activeadmin_addons icon indicating copy to clipboard operation
activeadmin_addons copied to clipboard

Allow overriding default select2 initialization configuration options

Open debreczeni opened this issue 6 years ago • 0 comments

I had to override the defaults with:

# config/initializers/activeadmin_addons.rb

ActiveadminAddons.setup do |config|
  # Override default initialization configuration for select2 input in ActiveAdminAddons
  # https://select2.org/configuration/options-api
  # single elements can also be configured through data attributes:
  # f.input attribute, as: :select, input_html: { data: { dropdown_auto_width: true, width: 'auto' } }
  config.select_config = {
    width: 'auto',
    dropdownAutoWidth: true
  }
end

and add the following CSS to make the selects usable, whether they appear as horizontal (default date_select for example with 3 dropdowns) or vertical selects (one label / one dropdown):

// app/assets/stylesheets/active_admin.css.scss

.select2-selection__rendered {
  margin-right: 11px;

  .select2-selection__clear {
    right: -11px;

    &:hover {
      color: #c00;
    }
  }
}

debreczeni avatar Mar 21 '19 12:03 debreczeni