Sha256: f231bf5a1acfa93dba4c2f88ea1e55129efbf50c163b2b51e7ad5678d97395e9

Contents?: true

Size: 962 Bytes

Versions: 82

Compression:

Stored size: 962 Bytes

Contents

InlineForms::SPECIAL_COLUMN_TYPES[:dropdown_with_integers]=:integer

# dropdown_with_integers generates a dropdown menu
# with the given list of integers as options
#
# values must be a Range or a one-dimensional array of Integers
def dropdown_with_integers_show(object, attribute)
  values = attribute_values(object, attribute)
  link_to_inline_edit object, attribute, values[object.send(attribute)][1]
end

def dropdown_with_integers_edit(object, attribute)
  # the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form!
  values = attribute_values(object, attribute)
  collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_sym, values, 'first', 'last', :selected => object.send(attribute))
end

def dropdown_with_integers_update(object, attribute)
  object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym]
end

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
inline_forms-1.0.0 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.25 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.24 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.23 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.22 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.21 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.20 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.19 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.18 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.17 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.16 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.15 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.14 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.13 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.12 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.11 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.10 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.9 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.8 app/helpers/form_elements/dropdown_with_integers.rb
inline_forms-0.9.7 app/helpers/form_elements/dropdown_with_integers.rb