Class: Formtastic::SurveyorBuilder
- Inherits:
-
SemanticFormBuilder
- Object
- SemanticFormBuilder
- Formtastic::SurveyorBuilder
- Defined in:
- lib/formtastic/surveyor_builder.rb
Instance Method Summary (collapse)
- - (Object) date_input(method, options)
- - (Object) quiet_input(method, options = {})
- - (Object) surveyor_check_boxes_input(method, options)
- - (Object) surveyor_radio_input(method, options)
Instance Method Details
- (Object) date_input(method, options)
81 82 83 |
# File 'lib/formtastic/surveyor_builder.rb', line 81 def date_input(method, ) string_input(method, ) end |
- (Object) quiet_input(method, options = {})
4 5 6 7 8 |
# File 'lib/formtastic/surveyor_builder.rb', line 4 def quiet_input(method, = {}) = .delete(:input_html) || () [:id] ||= generate_html_id(method, "") hidden_field(method, ) end |
- (Object) surveyor_check_boxes_input(method, options)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/formtastic/surveyor_builder.rb', line 9 def surveyor_check_boxes_input(method, ) collection = find_collection_for_column(method, ) = .delete(:input_html) || {} input_name = generate_association_input_name(method) hidden_fields = .delete(:hidden_fields) value_as_class = .delete(:value_as_class) unchecked_value = .delete(:unchecked_value) || '' = { :name => "#{@object_name}[#{input_name}][]" }.merge() input_ids = [] selected_values = find_selected_values_for_column(method, ) disabled_option_is_present = .key?(:disabled) disabled_values = [*[:disabled]] if disabled_option_is_present = value_as_class ? { :class => [method.to_s.singularize, 'default'].join('_') } : {} list_item_content = collection.map do |c| label = c.is_a?(Array) ? c.first : c value = c.is_a?(Array) ? c.last : c input_id = generate_html_id(input_name, value.to_s.gsub(/\s/, '_').gsub(/\W/, '').downcase) input_ids << input_id [:checked] = selected_values.include?(value) [:disabled] = disabled_values.include?(value) if disabled_option_is_present [:id] = input_id li_content = create_hidden_field_for_check_boxes(input_name, value_as_class) unless hidden_fields li_content << template.content_tag(:label, Formtastic::Util.html_safe("#{create_check_boxes(input_name, , value, unchecked_value, hidden_fields)} #{escape_html_entities(label)}"), :for => input_id ) li_content << basic_input_helper(:text_field, :string, :string_value, ) if [:response_class] == "other_and_string" li_content << basic_input_helper(:text_field, :string, :string_value, ) if %w(string other_and_string).include?([:response_class]) li_content << basic_input_helper(:text_area, :text, :text_value, ) if [:response_class] == "text" # li_options = value_as_class ? { :class => [method.to_s.singularize, value.to_s.downcase].join('_') } : {} Formtastic::Util.html_safe(li_content) end Formtastic::Util.html_safe(list_item_content.join) end |
- (Object) surveyor_radio_input(method, options)
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/formtastic/surveyor_builder.rb', line 51 def surveyor_radio_input(method, ) collection = find_collection_for_column(method, ) = ().merge(.delete(:input_html) || {}) input_name = generate_association_input_name(method) value_as_class = .delete(:value_as_class) input_ids = [] list_item_content = collection.map do |c| label = c.is_a?(Array) ? c.first : c value = c.is_a?(Array) ? c.last : c input_id = generate_html_id(input_name, value.to_s.gsub(/\s/, '_').gsub(/\W/, '').downcase) input_ids << input_id [:id] = input_id li_content = template.content_tag(:label, Formtastic::Util.html_safe("#{(input_name, value, )} #{escape_html_entities(label)}"), :for => input_id ) li_content << basic_input_helper(:text_field, :string, :integer_value, ) if [:response_class] == 'integer' li_content << basic_input_helper(:text_field, :string, :string_value, ) if [:response_class] == 'string' # li_options = value_as_class ? { :class => [method.to_s.singularize, value.to_s.downcase].join('_') } : {} Formtastic::Util.html_safe(li_content) end Formtastic::Util.html_safe(list_item_content.join) end |