Sha256: b6aa7b91e39557b6737d64c22c8ababd4a5603bc49c61d6848bafecf4e954039
Contents?: true
Size: 876 Bytes
Versions: 40
Compression:
Stored size: 876 Bytes
Contents
# frozen_string_literal: true module EacRailsUtils module CommonFormHelper class FormBuilder module SelectField def select_field(field_name, options = {}) options = options.dup field(field_name, options) do form.select(field_name, select_options(field_name, options), options, options[:html] || {}) end end private def select_options(field_name, options) options[:options] || listable_select_options(field_name) || raise('No options found') end def listable_select_options(field_name) return nil unless model_instance.class.respond_to?(:lists) return nil unless model_instance.class.lists.respond_to?(field_name) model_instance.class.lists.send(field_name).options end end end end end
Version data entries
40 entries across 40 versions & 1 rubygems