开发者

Forms and form validation in Rails 3: build your own vs Formtastic vs SimpleForm vs other gems?

Forms offer no differentiation value for your service, but most web sites need them obviously.

So far, we're building our own forms, but we would like to see how others approach forms -- especially form validation and attractive error messages -- and whether there is a more streamlined approach we're missing.

We're on Rails 3.

1) Our research has yielded Formtastic and SimpleForm as the most popular gems. Which others have you tried?

2) What are the pros/cons for your current approach?

3) We can't find demos (live 开发者_开发技巧working examples) of Formtastic or SimpleForm. Yes, we could download the code and do it ourselves, but we're wondering if there are live examples we could play with first.

Thanks!


I would most definitely recommend to use either formtastic or simple-form. While both are somewhat similar (their API is almost identical), the philosophy is a bit different.

Formtastic to get started, it is supplied with a default css, it generates semantically rich and correct markup. SimpleForm has the advantage that is extremely configurable, and will allow to configure the HTML that is generated completely. And it does not come with a default css. So simple-form should be used if you are trying to implement a HTML that is defined by someone else (e.g. your designer). Formtastic is just awesome if there is no specific (beforehand defined) design to follow.

With Formtastic being on the brink of their 2.0 release, it will get even more easier to extent Formtastic, I wholeheartedly recommend using Formtastic. The amount of code you need to write to get a nice form is so much less, it is so much easier, that it seems just plain stupid to not use it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜