How would I go about having Formtastic automatically add the class “required” to elements that are required by rails validation?
I see that you can create custom inputs by adding the specified inputs in app/inputs but I don’t see a way to check to see if it’s required.
I’m assuming it would be something like:
class StringInput < Formtastic::Inputs::StringInput
include Base::Stringish
include Base::Validations
def input_html_options
if required?
super.merge(:class => "required")
end
end
end
but it’s not working 😐
I’m sure it does this anyway if you just ask it to:
(this is Ruby 1.9 syntax)