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, #tags

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



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/red_cap/form/fields.rb', line 166

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(responses).keys.include?("501")
    right[-1] = [other_text_field("501")&.value(responses)]
  end

  Hash[left.zip(right)]
end