I have an Event Model with a parent Place association
class Event < ActiveRecord::Base
belongs_to :place
accepts_nested_attributes_for :place
attr_accessible :place_attributes
In a new event registration form, the user should have the choice to :
- select from an existing Place
- enter a new Place in a nested form
= simple_form_for @event
= f.association :place, :collection => Place.all(:order =>
‘label’), :prompt => “Choose an Place”, :label => false
…
= f.simple_fields_for :place do |pf|
#geolocation.form-inputs
= pf.simple_fields_for :geolocation do |g|
= render “backoffice/places/
geolocation_fields”, :f => g
should I manage that with a jQuery script ?
- when user select a place , it will clear the nested place form
- when user enter data in the nested place form, it will reinitiate
the place select
how can I manage the duplicated attribute param ? ( should the js
script add/remove the corresponding html elements ?)
I’m a little bit lost in translation…