Files
nairobi/lib/consul_form_builder.rb
Javi Martín ae6fab9f5e Inherit from builder instead of monkey patching it
We were monkey-patching FoundationRailsHelper::Formbuilder, which made
form customization difficult. We can inherit from it, which is the
standard way of extending what an existing class does, and make our form
the default one.
2019-10-05 16:01:58 +02:00

16 lines
466 B
Ruby

class ConsulFormBuilder < FoundationRailsHelper::FormBuilder
def cktext_area(attribute, options)
field(attribute, options) do |opts|
super(attribute, opts)
end
end
def enum_select(attribute, options = {}, html_options = {})
choices = object.class.send(attribute.to_s.pluralize).keys.map do |name|
[object.class.human_attribute_name("#{attribute}.#{name}"), name]
end
select attribute, choices, options, html_options
end
end