Class: SurveyorCheckBoxesInput
Instance Method Summary
collapse
#input_html_options_with, #response_class_to_method
Instance Method Details
#checked?(value) ⇒ Boolean
20
21
22
|
# File 'app/inputs/surveyor_check_boxes_input.rb', line 20
def checked?(value)
selected_values.include?(value.to_s)
end
|
#choice_html(choice) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/inputs/surveyor_check_boxes_input.rb', line 6
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
|
#disabled?(value) ⇒ Boolean
23
24
25
|
# File 'app/inputs/surveyor_check_boxes_input.rb', line 23
def disabled?(value)
disabled_values.include?(value) || input_html_options[:disabled] == true
end
|
#make_selected_values ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'app/inputs/surveyor_check_boxes_input.rb', line 26
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
|
#to_html ⇒ Object
3
4
5
|
# File 'app/inputs/surveyor_check_boxes_input.rb', line 3
def to_html
super
end
|