Sha256: 646ce91e801c98d75ced561e3657d04ce2120767ba93b76ae2f52b80c15efb30

Contents?: true

Size: 912 Bytes

Versions: 52

Compression:

Stored size: 912 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) ? t(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

52 entries across 52 versions & 1 rubygems

Version Path
inline_forms-3.0.44 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.43 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.42 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.41 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.40 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.39 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.38 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.37 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.36 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.35 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.34 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.32 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.31 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.30 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.29 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.28 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.27 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.26 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.25 lib/app/helpers/form_elements/dropdown_with_values.rb
inline_forms-3.0.24 lib/app/helpers/form_elements/dropdown_with_values.rb