Something like this in application.rb:
# Configure application generators
config.app_generators do |g|
g.form_builder Formtastic::SemanticFormBuilder
end
If I do so I get an error when I try to scaffold a model:
Expected Thor class, got Formtastic::SemanticFormBuilder
Is it possible to set Formtastic as default form builder?
Updated.
I have tried Simple forms and it's really awesome (Thanks to nathanvda
). The DSL is almost the same as Formtastic has. The only important difference for me is in customizing button labels. In formtastic it's possible to use resource file (formtastic.yml) to set different labels for the same model and action. Sometimes it's necessary, for example in Devise views. But it costs nothing to switch from formtastic to simple forms even in this case as it's possible to do it in this pretty simple way:
= f.submit t("customized_button_label")
Now about the original question. When I installed simple forms it 开发者_StackOverflowcreates template in lib/templates/haml/scaffold directory which will be used with scaffold. Straightforward.
I am not entirely sure about formtastic, either it does this straight out of the box, so not configuration needed; or not at all.
But what i do know: simple_form does provide scaffolding, even configurable which is totally awesome. The DSL between formtastic and simple_form is close to identical, but with simple_form the level of configuration is much better. You have total control how a form should be scaffolded, you have total control how a single field is turned into html. Pretty awesome.
You can find a quick introduction here.
精彩评论