Sha256: 51c79dfc688fdd8889bdebd2ef708b330c0b401e66dac2a3ea8ff3a5140d1a6f

Contents?: true

Size: 910 Bytes

Versions: 30

Compression:

Stored size: 910 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, object.send(attribute) ? values.assoc(object.send(attribute))[1] : "<i class='fi-plus'></i>".html_safe
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

30 entries across 30 versions & 1 rubygems

Version Path
inline_forms-3.0.10 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.9 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.8 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.7 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.6 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.5 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.4 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.3 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.2 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.1 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-1.6.70 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-1.6.69 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-1.6.68 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-1.6.67 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-1.6.66 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-1.6.65 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-1.6.64 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-1.6.63 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-1.6.62 lib/app/helpers/form_elements/dropdown_with_values.rb