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

#associated_fields, #attributes, #options

Instance Method Summary collapse

Methods inherited from CheckboxesWithOther

#other?, #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

#value(responses) ⇒ Object



158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/red_cap/form/fields.rb', line 158

def value responses
  left = selected_options(responses).values

  right = selected_options(responses).keys.map do |key|
    checkbox_fields_for(key).map do |field|
      field.value(responses)
    end
  end

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

  Hash[left.zip(right)]
end