Design issue : one parent attribute, 2 ways to input it .... ( association select for existing , nested form for new one )

19 views
Skip to first unread message

erwin

unread,
Oct 9, 2012, 10:46:37 AM10/9/12
to SimpleForm
I guess it's not a simple_form related issue, but maybe some user
already had this 'interrogation' w form

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.....

erwin

unread,
Oct 9, 2012, 11:52:21 AM10/9/12
to SimpleForm

erwin

unread,
Oct 9, 2012, 12:20:30 PM10/9/12
to SimpleForm
sorry ... hit the return key twice .. but only one issue ...
Reply all
Reply to author
Forward
0 new messages