Formtastic is a Rails plugin by Justin French that aims to take the headaches out of building forms in Rails views. To build it, Justin wrote down how he'd like a form creation DSL to look and then worked backwards to building the code necessary to implement that DSL. The result is a very obvious and straightforward form creation DSL.

Formtastic doesn't just make it easy to whip up basic forms, though. It has some significant advantages over similar plugins:

  • It's Rails 2.3 ready
  • It's under active development (the last update was yesterday)
  • It supports internationalization
  • It has full spec coverage
  • It can handle belongs_to, has_many, and has_and_belongs_to_many associations out of the box, rendering multi-selects and radio inputs where necessary!
  • It doesn't screw around with the existing Rails form helpers

Here's a large form example straight from Formtastic's documentation (which is pretty thorough, you'll be glad to know):

<% semantic_form_for @article do |form| %>

  <% form.inputs :name => "Basic" do %>
<%= form.input :title %>
<%= form.input :body %>
<%= form.input :section %>
<%= form.input :publication_state, :as => :radio %>
<%= form.input :category %>
<%= form.input :allow_comments, :label => "Allow commenting on this article" %>
<% end %> <% form.inputs :name => "Advanced" do %>
<%= form.input :keywords, :required => false, :hint => "Example: ruby, rails, forms" %>
<%= form.input :extract, :required => false %>
<%= form.input :description, :required => false %>
<%= form.input :url_title, :required => false %>
<% end %> <% form.inputs :name => "Author", :for => :author do |author_form| %>
<%= author_form.input :first_name %>
<%= author_form.input :last_name %>
<% end %> <% form.buttons do %>
<%= form.commit_button %>
<% end %> <% end %>

The result is a clean bundle of HTML. Groovy, right? So get reading the documentation and give it a try. It's an awesome plugin.

最新文章

  1. phpnow修改默认站点根目录的方法
  2. GitHub上我收藏Java及Android的项目Demo
  3. 安卓开发-See the log file\.metadata\.log.
  4. 感受机房管理化繁为简-新款KVM使用心得
  5. sqlserver 2008 R2 分区表测试
  6. oracle连接进程数设置
  7. hdu1175连连看
  8. [题解]小X的液体混合
  9. BFC特性下多栏自适应布局
  10. [Swift]LeetCode337. 打家劫舍 III | House Robber III
  11. phpstorm设置背景图片
  12. requests库入门07-patch请求
  13. HSmartWindowControl 之 摄像头实时显示( 使用 WPF )
  14. 网络基础&#160;利用vnc&#160;viewer访问在vmware虚拟机上的linux
  15. RAID卡的缓存与磁盘自带的缓存的关系
  16. GPO配置时的注意事项
  17. top(topas),vmstat,iostat在linux和AIX操作系统下显示情况
  18. 51nod部分容斥题解
  19. 以二进制的形式查看文件 Linux之od命令详解
  20. 第三篇 Fiddler数据包分析

热门文章

  1. C#使用oledb操作excel文件的方法
  2. c# 控制台应用程序怎么隐藏黑窗口
  3. 3-WIN10系统及开发工具支持
  4. pageadmin CMS网站制作教程:模板概念解释
  5. css3效果隔两秒旋转然后停两秒再继续旋转,无限循环
  6. django orm 以列表作为筛选条件进行查询
  7. spring json的支持
  8. OC 中的属性
  9. linux文件系统底层原理
  10. WPF一步步开发XMPP IM客户端1:入门