Class: REDCap::Form::CheckboxesWithCheckboxesOrOther

Inherits:
CheckboxesWithOther 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

#attributes, #form, #responses

Instance Method Summary collapse

Methods inherited from CheckboxesWithOther

#other_text_field

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

#valueObject



141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/red_cap/form/fields.rb', line 141

def value
  left = selected_options.values

  right = selected_options.keys.map do |key|
    checkbox_fields_for(key).map(&:value)
  end

  if selected_options.keys.include?("501")
    right[-1] = [other_text_field&.value]
  end

  Hash[left.zip(right)]
end