Sha256: e0b1c6e3c312ed2cd478fed291c9541cc210ed3ab6d764e017906edd411bd8ec

Contents?: true

Size: 1.42 KB

Versions: 11

Compression:

Stored size: 1.42 KB

Contents

class SurveyorCheckBoxesInput < Formtastic::Inputs::CheckBoxesInput
  include Surveyor::Helpers::FormtasticCustomInput
  def to_html
    super
  end
  def choice_html(choice)
    output = "" 
    output << template.content_tag(:label,
      hidden_fields? ?
        check_box_with_hidden_input(choice) :
        check_box_without_hidden_input(choice) <<
      choice_label(choice),
      label_html_options.merge(:for => choice_input_dom_id(choice), :class => nil)
    )
    output << builder.text_field(:response_other, input_html_options_with(choice, :response_other)) if options[:response_class] == "other_and_string"
    output << builder.text_field(response_class_to_method(options[:response_class]), input_html_options_with(choice, options[:response_class])) if %w(date datetime time float integer string other_and_string).include? options[:response_class]
    output << builder.text_area(:text_value, input_html_options_with(choice, :text_value)) if options[:response_class] == "text"
    output.html_safe
  end
  def checked?(value)
    selected_values.include?(value.to_s)
  end
  def disabled?(value)
    disabled_values.include?(value) || input_html_options[:disabled] == true
  end
  def make_selected_values
    if object.respond_to?(method)
      selected_items = [object.send(method)].compact.flatten.map(&:to_s)
      
      [*selected_items.map { |o| send_or_call_or_object(value_method, o) }].compact
    else
      []
    end
  end
end

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
upgrade_surveyor-1.4.2 app/inputs/surveyor_check_boxes_input.rb
affectiva-surveyor-1.5.0.pre.disco.2 app/inputs/surveyor_check_boxes_input.rb
hssc_surveyor-1.4.3.pre app/inputs/surveyor_check_boxes_input.rb
hssc_surveyor-1.4.2.pre app/inputs/surveyor_check_boxes_input.rb
hssc_surveyor-1.4.1.pre app/inputs/surveyor_check_boxes_input.rb
surveyor-1.4.0 app/inputs/surveyor_check_boxes_input.rb
surveyor-1.3.0 app/inputs/surveyor_check_boxes_input.rb
surveyor-1.2.0 app/inputs/surveyor_check_boxes_input.rb
surveyor-1.1.0 app/inputs/surveyor_check_boxes_input.rb
surveyor-1.0.1 app/inputs/surveyor_check_boxes_input.rb
surveyor-1.0.0 app/inputs/surveyor_check_boxes_input.rb