Sha256: 5d99715de81c160e05d89ade7d0c758821b91bb1ef21e67184eceea8540e6745

Contents?: true

Size: 408 Bytes

Versions: 2

Compression:

Stored size: 408 Bytes

Contents

require 'fields/controllers/main_controller'

module Fields
  class SelectController < MainController
    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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
volt-fields-0.1.2 app/fields/controllers/select_controller.rb
volt-fields-0.1.1 app/fields/controllers/select_controller.rb