Sha256: 019c2dcc431e5d225bcf34b5d4567febd7ddc282880a5e57110cfb34b78a1d98

Contents?: true

Size: 802 Bytes

Versions: 8

Compression:

Stored size: 802 Bytes

Contents

module InlineFormsHelper
    InlineForms::SPECIAL_MIGRATION_TYPES[:dropdown_with_values]=:integer
  # dropdown_with_values
  def dropdown_with_values_show(object, attribute, values)
    link_to_inline_edit object, attribute, values[object.send(attribute)], values
  end
  def dropdown_with_values_edit(object, attribute, values)
    # 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!
    collection_select( ('_' + object.class.to_s.downcase).to_sym, attribute.to_sym, values, 'first', 'last', :selected => object.send(attribute))
  end
  def dropdown_with_values_update(object, attribute, values)
    object[attribute.to_sym] = params[('_' + object.class.to_s.downcase).to_sym][attribute.to_sym]
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
inline_forms-0.7.1 app/helpers/form_elements/dropdown_with_values.rb
inline_forms-0.7.0 app/helpers/form_elements/dropdown_with_values.rb
inline_forms-0.6.5 app/helpers/form_elements/dropdown_with_values.rb
inline_forms-0.6.4 app/helpers/form_elements/dropdown_with_values.rb
inline_forms-0.6.3 app/helpers/form_elements/dropdown_with_values.rb
inline_forms-0.6.2 app/helpers/form_elements/dropdown_with_values.rb
inline_forms-0.6.1 app/helpers/form_elements/dropdown_with_values.rb
inline_forms-0.6.0 app/helpers/form_elements/dropdown_with_values.rb