I'm looking for some guidance to make a custom form with ActiveAdmin. This is not a regular form, but I actually need some JavaScript on it. However, I'm not familiar with ActiveAdmin right now.
I have a form that will collect a Product list. Every time I add a Product to the list, I need to recalculate the sub-total for the order (based on quantity and unique price).
For adding the products I'm using regular Formtastic, like this:
f.inputs "Product List" do
f.has_many :product_lists do |detail|
detail.input :good_id, :as => :select,
:collection => Good.accessible_by(current_ability, :read),
:input_html => { class: 'chosen-select' },
:include_blank => true
detail.input :quantity, :input_html => { :value => 1 }
end
end
However, I came across to multiple questions:
- How should I recalculate the sub-totals every time I add a new product on the list? Should I use a custom collection action? I was even considering a Backbone App inside of it, for handling the whole process.
- Is there a better way, instead of using a Custom Action?
- Is there a good way to use a custom action ONLY for the new form? I was able to make a new one, but I was not able to have control over the form.
- How can I have better control of the form panel? I was not able to add panels inside the form block :(.