I want to add :validate => true
to every formtastic form in my Rails 3 app. I've looked over the code to Formtastic and don't see an obvious hook for that. Before forking it and writing the code myself, I wanted to see if anyone had already solved this problem.
Sorry to answer my own question but Justin French confirmed what I suspected. There is no current facility to do this in Formtastic. He suggested a wrapper, which I implemented as follows:
def validated_form_for(record_name_or_array, *args, &proc)
options = args.extract_options!
options.reverse_merge!({:validate => true})
semantic_form_for(record_name_or_array, options, &proc)
end
This handles the case where you want forms that are automatically client-side validated, but wish to be able to override it on a case by case basis.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.