Class: Former::FormBuilder

Inherits:
ActionView::Helpers::FormBuilder
  • Object
show all
Defined in:
lib/former.rb

Instance Method Summary collapse

Instance Method Details

#radio_button_group(name, values, *args) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/former.rb', line 23

def radio_button_group(name, values, *args)
  options = Hash === args.last ? args.pop : {}

  result = values.inject("") do |html, value|
    label = label("#{name}_#{value}", value)
    rb = radio_button(name, value)
    unless options[:label_position] == :after
      content = "#{label} #{rb}"
    else
      content = "#{rb} #{label}"
    end

    html << "<li>#{content}</li>"
  end

  "<ul>#{result}</ul>"
end