Sha256: 0a5cd4a8a1bd418e9eb55426bbf67fb64a3c9a37f7a90e107907dc97eb645934

Contents?: true

Size: 847 Bytes

Versions: 6

Compression:

Stored size: 847 Bytes

Contents

# -*- encoding : utf-8 -*-
InlineForms::SPECIAL_COLUMN_TYPES[:dropdown_with_values]=:integer

# dropdown_with_values
def dropdown_with_values_show(object, attribute)
  values = attribute_values(object, attribute)
  link_to_inline_edit object, attribute, values.assoc(object.send(attribute))[1]
end
def dropdown_with_values_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_values_update(object, attribute)
  object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym]
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
inline_forms-1.6.1 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-1.6.0 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-1.5.9 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-1.5.8 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-1.5.7 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-1.5.6 lib/app/helpers/form_elements/dropdown_with_values.rb