Class: REDCap::Form::CheckboxesWithOther

Inherits:
Checkboxes show all
Defined in:
lib/red_cap/form/fields.rb

Constant Summary

Constants inherited from Field

Field::KEYS

Instance Attribute Summary

Attributes inherited from Field

#associated_fields, #attributes, #options

Instance Method Summary collapse

Methods inherited from RadioButtons

#options

Methods inherited from Field

#method_missing

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class REDCap::Form::Field

Instance Method Details

#other?(key) ⇒ Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/red_cap/form/fields.rb', line 129

def other? key
  other_text_field(key)
end

#other_text_field(key) ⇒ Object



125
126
127
# File 'lib/red_cap/form/fields.rb', line 125

def other_text_field key
  associated_fields_for_key(key).find(&:text?)
end

#value(responses) ⇒ Object



115
116
117
118
119
120
121
122
123
# File 'lib/red_cap/form/fields.rb', line 115

def value responses
  selected_options(responses).map do |key, value|
    if other?(key)
      "#{value}: #{other_text_field(key).value(responses)}"
    else
      value
    end
  end
end