Use columns in the ActiveAdmin form.

I am using ActiveAdmin for my Rails project. How do I style the resource form view using columns

like in a view view inside a relationship has_many

(column-wise, I mean have two or three separate blocks of floating content)?

Here is the code I tried to set up (I used .arb views):

f.inputs t('activerecord.models.slide.other') do
  f.has_many :slides, heading: false do |item|

    # I would like to be a first column
    item.input :image,
                 as: :file,
                 label: I18n.t('form.label.slide'),
                 hint: retina_image_tag(item.object, :image, :preview)
    item.input :online,
                 as: :boolean,
                 hint: I18n.t('form.hint.slide.online')

    if item.object.self_image?
      item.input :_destroy,
                   as: :boolean,
                   hint: I18n.t('form.hint.slide.destroy')
    end

    # I would like to be a second column
    item.translated_inputs 'Translated fields', switch_locale: true do |t|
      t.input :title, hint: I18n.t('form.hint.title')
      t.input :description,
                hint: I18n.t('form.hint.content')
    end
  end
end

      

Thank you for your help!

+3


source to share


1 answer


add custom CSS to erase the default AA styles. Apply float: left and width of half screen size.



    #active_admin_content 
      form.slider
        fieldset > ol
          li
            fieldset.inputs.has_many_fields > ol > li.input
              float: left
              clear: none
              width: 47% 
            &:nth-child(2)
              float: right
            &:not(.input)
              clear: both 

      

+2


source







All Articles