ActiveadminExpandableInputs

This GEM adds the ability for the user to minimize and maximize the inputs boxes in activeadmin.

Installation

Add this line to your application's Gemfile:

gem 'activeadmin_expandable_inputs'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activeadmin_expandable_inputs

Usage

Import the Assets

Add to application.js:

//= require activeadmin-expandable

Add to application.css

 *= require activeadmin-expandable

Create expandable elements

Add the class 'expandable' and 'in' (if you want it to start expanded) or 'out' (to start closed). Don't forget to put the class 'inputs' so you don't lose the box style.

Example:

ActiveAdmin.register AdminUser do
  form do |f|
    f.inputs "Admin Details", :class => 'inputs expandable in' do
      f.input :email
      f.input :password
      f.input :password_confirmation
    end
    f.actions
  end
end

You can add it to nested_resources too! This automatically adds a legend to the new inputs box based on the add button name.

For example:

ActiveAdmin.register Post do

  form do |f|
    f.inputs "Details" do
      f.input :title
      f.input :published_at, :label => "Publish Post At"
    end
    f.inputs "Content" do
      f.input :body
    end

    # The legend added to the inputs box it's based on the new_record button text. In this case, the text in the button will be 'Add Theme'. So the legend, will be 'Theme'.
    f.has_many :categories, :allow_destroy => true, :heading => 'Themes', :new_record => 'Add Theme', :class => 'inputs expandable in' do |cf|
      cf.input :title
    end
    f.actions
  end

end

Contributing

  1. Fork it ( http://github.com/arielschvartz/activeadmin_expandable_inputs/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request