Sha256: f5d3d99ea1e9c3ceee3ef80ea8838828df0565b80aa8a648123794449e8ac75b
Contents?: true
Size: 1.31 KB
Versions: 17
Compression:
Stored size: 1.31 KB
Contents
module Eac module CommonFormHelper class FormBuilder module RadioSelectField def radio_select_field(field_name, radios_values, options = {}) field(field_name, options) do radios(field_name, radios_values) end end private def radios(field_name, radios_values) b = ActiveSupport::SafeBuffer.new radios_values.each do |r| b << radio(field_name, r[0], r[1]) end b end def radio(field_name, value, label) helper.content_tag(:div, class: 'radio') do helper.content_tag(:label) do form.radio_button(field_name, value) << label end end end def extract_select_options(options) options.extract!(:prompt, :include_blank) end def extract_association_key(field_name, options, key, method) return options.delete(key) if options.key?(key) if model_instance.class.respond_to?(:reflect_on_association) return model_instance.class.reflect_on_association(field_name).send(method) end fail "#{model_instance.class} não possui um método \"reflect_on_association\". " \ "Defina explicitamente a opção :#{key}" end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems