Sha256: ed3b3e926880d0985b1253450e3cb5f54d0b0531c3196c47e77e80546b3e990f

Contents?: true

Size: 892 Bytes

Versions: 145

Compression:

Stored size: 892 Bytes

Contents

# -*- encoding : utf-8 -*-
InlineForms::SPECIAL_COLUMN_TYPES[:radio_button]=:integer
# radio buttons are integers in this version
# us like this:
#   [ :sex , "gender", :radio_button, { 1 => 'male', 2 => 'female' } ],

def radio_button_show(object, attribute)
  values = attribute_values(object, attribute)
  link_to_inline_edit object, attribute, object.send(attribute) ? values.assoc(object.send(attribute))[1] : ""
end

def radio_button_edit(object, attribute)
  out =''
  values = attribute_values(object, attribute)
  values.each do |key,value|
    out << "<div class='row #{cycle('odd', 'even')}'>"
    out << radio_button_tag(attribute.to_s, key, key == object.send(attribute))
    out << "<label for=#{key}>#{value}</label>"
    out << '</div>'
  end
  out.html_safe
end

def radio_button_update(object, attribute)
  object[attribute.to_s.to_sym] = params[attribute.to_s.to_sym]
end

Version data entries

145 entries across 145 versions & 1 rubygems

Version Path
inline_forms-5.0.18 lib/app/helpers/form_elements/radio_button.rb
inline_forms-5.0.17 lib/app/helpers/form_elements/radio_button.rb
inline_forms-5.0.16 lib/app/helpers/form_elements/radio_button.rb
inline_forms-5.0.15 lib/app/helpers/form_elements/radio_button.rb
inline_forms-5.0.6 lib/app/helpers/form_elements/radio_button.rb
inline_forms-5.0.4 lib/app/helpers/form_elements/radio_button.rb
inline_forms-5.0.0 lib/app/helpers/form_elements/radio_button.rb
inline_forms-3.2.11 lib/app/helpers/form_elements/radio_button.rb
inline_forms-3.2.10 lib/app/helpers/form_elements/radio_button.rb
inline_forms-3.2.9 lib/app/helpers/form_elements/radio_button.rb
inline_forms-3.2.8 lib/app/helpers/form_elements/radio_button.rb
inline_forms-3.2.7 lib/app/helpers/form_elements/radio_button.rb
inline_forms-3.2.6 lib/app/helpers/form_elements/radio_button.rb
inline_forms-3.2.5 lib/app/helpers/form_elements/radio_button.rb
inline_forms-3.2.4 lib/app/helpers/form_elements/radio_button.rb
inline_forms-3.2.3 lib/app/helpers/form_elements/radio_button.rb
inline_forms-3.2.2 lib/app/helpers/form_elements/radio_button.rb
inline_forms-3.2.1 lib/app/helpers/form_elements/radio_button.rb
inline_forms-3.2.0 lib/app/helpers/form_elements/radio_button.rb
inline_forms-3.1.9 lib/app/helpers/form_elements/radio_button.rb