Class: Fields::SelectController

Inherits:
MainController
  • Object
show all
Defined in:
app/fields/controllers/select_controller.rb

Instance Method Summary collapse

Methods inherited from MainController

#blur, #errors, #label, #marked, #model, #setup_field

Instance Method Details

#optionsObject



5
6
7
8
9
10
11
12
# File 'app/fields/controllers/select_controller.rb', line 5

def options
  if attrs.options[0].is_a?(Hash)
    options = attrs.options
  else
    options = attrs.options.collect { |option| { value: option, label: option } }
  end
  options
end

#selected?(value) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/fields/controllers/select_controller.rb', line 14

def selected?(value)
  true if value == model.send(@field_name)
end