Method: MuckEngine::FormBuilder#state_select
- Defined in:
- lib/muck-engine/form_builder.rb
#state_select(method, options = {}, html_options = {}, additional_state = nil) ⇒ Object
creates a select control with states. Default id is ‘states’. If ‘retain’ is passed for the class value the value of this control will be written into a cookie with the key ‘states’.
| 149 150 151 152 153 154 | # File 'lib/muck-engine/form_builder.rb', line 149 def state_select(method, = {}, = {}, additional_state = nil) country_id_field_name = .delete(:country_id) || 'country_id' country_id = get_instance_object_value(country_id_field_name) @states = country_id.nil? ? [] : (additional_state ? [additional_state] : []) + State.find(:all, :conditions => ["country_id = ?", country_id], :order => "name asc") self.(method, I18n.t('muck.engine.choose_state'), @states, .merge(:prompt => I18n.t('muck.engine.select_state_prompt'), :wrapper_id => 'states-container'), .merge(:id => 'states')) end |