Class: Conjoin::FormBuilder::RadioInput
- Defined in:
- lib/conjoin/inputs/radio.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Input
#app, #data, #options, #record
Instance Method Summary collapse
Methods inherited from Input
#errors?, #id, #initialize, #nested_name, #render
Constructor Details
This class inherits a constructor from Conjoin::FormBuilder::Input
Instance Method Details
#display ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/conjoin/inputs/radio.rb', line 4 def display [:type] = :radio [:class].gsub!(/form-control/, '') radios = [:radios] || [:yes, :no] mab do radios.each_with_index do |name, i| opts = .dup name = name.to_s opts[:value] = name opts[:id] = "#{[:id]}_#{i}" if (opts[:value] == 'no' and data.value == 'no') \ or (opts[:value] == 'yes' and data.value == 'yes') \ or (opts[:value] == data.value) opts[:checked] = 'checked' else opts.delete :checked end label class: 'radio-inline' do input opts text! name.humanize end end end end |