Sha256: 2ff4f83477ddc2d989a230d57a31cb8b33ec99785510a55c3b1bc617c6d5fb4c

Contents?: true

Size: 954 Bytes

Versions: 75

Compression:

Stored size: 954 Bytes

Contents

InlineForms::SPECIAL_COLUMN_TYPES[:scale_with_values]=:integer

# scale_with_values generates a scale
# with the given list of values as options
#
# values must be a hash { integer => string, ... } or an one-dimensional array of strings
def scale_with_values_show(object, attribute)
  values = attribute_values(object, attribute)
  link_to_inline_edit object, attribute, values[object.send(attribute)][1]
end

def scale_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 scale_with_values_update(object, attribute)
  object[attribute.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_sym]
end

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
inline_forms-1.3.12 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.3.11 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.3.10 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.3.9 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.3.8 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.3.7 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.3.6 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.3.5 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.3.4 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.3.3 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.3.2 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.3.1 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.3.0 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.2.9 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.2.8 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.2.7 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.2.5 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.2.4 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.2.3 lib/app/helpers/form_elements/scale_with_values.rb
inline_forms-1.2.2 lib/app/helpers/form_elements/scale_with_values.rb