Module: Selections::FormBuilderExtensions

Defined in:
lib/selections/form_builder_extensions.rb

Defined Under Namespace

Classes: SelectionTag

Instance Method Summary collapse

Instance Method Details

#radios(field, options = {}) ⇒ Object

Build a radio button list based field name finding items within Selection

Example

form_for(@ticket) do |f|
  f.select :priority

options

  • system_code - Overrides the automatic system_code name based on the fieldname and looks up the list of items in Selection



29
30
31
32
33
# File 'lib/selections/form_builder_extensions.rb', line 29

def radios(field, options = {})
  html_options = options.clone
  html_options.delete_if {|key, value| key == :system_code}
  SelectionTag.new(self, object, field, options, html_options).radio_tag
end

#selections(field, options = {}, html_options = {}) ⇒ Object

Create a select list based on the field name finding items within Selection.

Example

form_for(@ticket) do |f|
  f.select("priority")

Uses priority_id from the ticket table and creates options list based on items in Selection table with a system_code of either priority or ticket_priority

options = {} and html_options = {} suport all the keys as the rails library select_tag does.

options

  • system_code - Overrides the automatic system_code name based on the fieldname and looks up the list of items in Selection



17
18
19
# File 'lib/selections/form_builder_extensions.rb', line 17

def selections(field, options = {}, html_options = {})
  SelectionTag.new(self, object, field, options, html_options).select_tag
end