# formnestic [](https://travis-ci.org/jameshuynh/formnestic) [](https://codeclimate.com/github/jameshuynh/formnestic) An extension of famous [Formtastic Form Builder](https://github.com/justinfrench/formtastic) to make building nested and association form with nested model addable and removable ability extremely easy and simple. ### Compatibility - Formnestic gem requires ``formtastic`` gem version ``2.2.1`` - Formnestic gem is Rails 3 and Rails 4 compatible ### Installation Add Formnestic to your Gemfile and run ``bundle install``: ```ruby gem "formnestic", '~> 1.0.1' ``` then run the installation ```bash bundle exec rails g formnestic:install ``` ### Features - Table form with row addable and removable - List form with entry addable and removable ### Usage Usage for rails 3 and rails 4 are almost the same, the only difference is that in Rails 4, you will need to remove all the ``attr_accessible`` in Rails 3 and use strong parameters in rails controller. Basically, you can now add the following options into ``semantic_fields_for`` call in Formtastic - ``display_type``: If you want your nested form to have table style, you can supply in ``table`` string - ``row_removable``: Allow nested model entry to be removed. - ``row_addable``: Allow nested model entry to be added. - ``min_entry``: Minimum number of nested model entries that is allowed. An alert will be shown if user tries to delete the last entry that meets this minumum number. - ``max_entry``: Maximum number of nested model entries that is allowed. Add button will be hidden if user has already added enough entries. - ``new_record_link_label``: The label to be displayed in the Add button. - ``table_headers``: A two(2) dimensional arrays, in which each array is presenting a row in table header row. For instance: ```rb [ [{label: 'Column 1', wrapper_html: {class: "big-column"}}, {label: 'Column 2'}], [{attr: :name}, {attr: :description}], ] ``` will yield a table header with 2 rows. The first row has 2 columns labeled ``Column 1`` and ``Column 2`` respectively, the second row labelled respected attribute's name of the nested model. The form view is the same between Rails 3 and Rails 4 ```erb <%= semantic_form_for @quiz_pool do |quiz_pool_form| %> <%= quiz_pool_form.inputs do %> <%= quiz_pool_form.input :title %> <%= quiz_pool_form.input :description %>