Module: CieloAssets::FormHelper

Defined in:
app/helpers/cielo_assets/form_helper.rb

Instance Method Summary collapse

Instance Method Details

#cielo_controls(object_name, method, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/helpers/cielo_assets/form_helper.rb', line 3

def cielo_controls object_name, method, options={}
  id    = options.delete(:id)    || :cielo_controls
  style = options.delete(:style) || :horizontal

  # object is deleted by radio_button helper,
  # so it must be re-added to options every flag
  object = options[:object]

   :div, id: id, class: style do
    %w(amex diners elo mastercard mastercard_securecode verified_by_visa visa).collect { |flag|
      options.merge! object: object
      radio = radio_button object_name, method, flag, options
      radio_id = radio.to_s.scan(/id=\"([^"]*)/).flatten.first
      label_options = options.merge class: "#{flag} selectable", for: radio_id
      [
        radio, label(radio_id, flag, label_options)
      ].join.html_safe
    }.join.html_safe
  end
end