All,
AS 2.1
Rails 2.1
I noticed that if I set form_ui = :select on a HABTM association column
in AS, then multiple select boxes are rendered.
What I wanted was actually a multi-select dropdown, so I overrode the
form column helper to provide a multiple select dropdown.
Of course, since this dropdown was one record instead of N (one checkbox
per choice), I named it a certain way, and then, in order to actually
have the save of the HABTM association work correctly, I overrode the
"create" method and hacked the params hash to emulate multiple
checkboxes, as seen below
(params[:record][:medical_facility_category_ids] is the name of the
multi-select dropdown form element, of course).
def create
#Hack the params hash so that this looks like a bunch of checkboxes
ids = params[:record][:medical_facility_category_ids]
if ids
params[:record][:medical_facility_categories] = {}
ids.each do |id|
params[:record][:medical_facility_categories][ids.index(id)] = {}
params[:record][:medical_facility_categories][ids.index(id)][:id] = id
end
end
super
end
I have 2 questions:
1) Is there a standard way to set up a multi-select dropdown in AS that
I just am not aware of?
2) If not, is this what I have to do, or is there something simpler?
Thanks,
Wes
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---