Module: CherrypickFormHelper

Defined in:
app/helpers/cherrypick_form_helper.rb

Instance Method Summary collapse

Instance Method Details

#cherrypick_form_group_text(fields, method, label_text, default_text_field_value, options = {}) ⇒ String

Creates a form group specifically for the cherrypick form with a label and a text field

Parameters:

  • fields (String)

    the output of calling fields_for

  • method (String)

    the method to call on the form object

  • label_text (String)

    the text to display in the label

  • default_text_field_value (String)

    the default value of the text field

  • options (Hash) (defaults to: {})

    the options to pass to the text field

Returns:

  • (String)

    the form group



27
28
29
30
31
32
33
34
35
36
37
# File 'app/helpers/cherrypick_form_helper.rb', line 27

def cherrypick_form_group_text(fields, method, label_text, default_text_field_value, options = {})
  (:div, class: 'form-group form-row') do
    fields.label(method, label_text, class: 'col-12 col-lg-8 col-form-label') +
      (:div, class: 'col-12 col-lg-4') do
        fields.text_field(
          method,
          { value: default_text_field_value, class: 'form-control text-right' }.merge(options)
        )
      end
  end
end

#cherrypick_strategy_radio_button(object_name, method, field_value, label_text, checked: false) ⇒ Object

Create a form group specifically for the cherrypick-strategy radio buttons

Parameters:

  • object_name (String)

    the name attribute of the radio button

  • method (String)

    the group the radio button belongs to

  • field_value (String)

    the value attribute of the radio button

  • label_text (String)

    the text to display in the label



10
11
12
13
14
15
16
17
# File 'app/helpers/cherrypick_form_helper.rb', line 10

def cherrypick_strategy_radio_button(object_name, method, field_value, label_text, checked: false)
  (:div, class: 'form-group form-row') do
    label_tag("#{object_name}[#{method}]_#{field_value}", label_text, class: 'col-12 col-lg-8 col-form-label') +
      (:div, class: 'col-12 col-lg-4') do
        radio_button(object_name, method, field_value, { checked: checked, class: 'form-control text-right' })
      end
  end
end