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.

Formtastic: Forms Made Crazy Easy for Rails Developers的更多相关文章

  1. Ruby on Rails 初次冲浪体验

    为了更好的阅读体验,欢迎訪问 作者博客原文 Rails is a web application development framework written in the Ruby language. ...

  2. Ruby On Rails 常用的精品Gem汇总

    首先需要注明一点,本文是原创的并不是从其它地方转载.所有的数据是我从 GitHub 和 RubyGems 上码下来的,数据的截取时间就是本文的发布日期. RubyGems 的下载量可以看到在用这个 g ...

  3. (转)Ruby On Rails 推荐 Gem 列表

    作者:尘缘,QQ:130775,来源:http://www.4wei.cn/archives/1002157 PHP的包管理Composer还在刚刚兴起的阶段,Ruby社区已经有很多成熟的Gem了,R ...

  4. JavaScript资源大全中文版(Awesome最新版)

    Awesome系列的JavaScript资源整理.awesome-javascript是sorrycc发起维护的 JS 资源列表,内容包括:包管理器.加载器.测试框架.运行器.QA.MVC框架和库.模 ...

  5. Top 22 Free Responsive HTML5 Admin & Dashboard Templates 2018

    Top 22 Free Responsive HTML5 Admin & Dashboard Templates 2018 May 18, 2018 Alex Ivanovs Website ...

  6. How To: Samba4 AD PDC + Windows XP, Vista and 7

    dnsmasq If you've been struggling with Samba3 domain controllers and NT4 style domains working with ...

  7. Knockout 新版应用开发教程之Observable Arrays

    假如你想到侦测和相应一个对象的改变,假如你想要侦测和响应一一组合集的改变,就要用observableArray 在许多场景都是很有用的,比如你要在UI上需要显示/编辑的一个列表数据集合,然后对集合进行 ...

  8. Git工作流指南:Gitflow工作流 Comparing Workflows

    Comparing Workflows The array of possible workflows can make it hard to know where to begin when imp ...

  9. git workflows

    https://www.atlassian.com/git/tutorials/comparing-workflows Comparing Workflows The array of possibl ...

随机推荐

  1. 【TFS错误】TF30063: 您没有访问 Microsoft-IIS/8.5 的权限

    问题现象 开发人员报告,所有的生成都失败了,日志显示下载源代码出错,系统提示错误信息为"-TF30063: 您没有访问 Microsoft-IIS/8.5 的权限-". 图1 - ...

  2. K8S+GitLab-自动化分布式部署ASP.NET Core(一) 部署环境

    一.部署流程介绍 开发人员通过Git上传asp.net core 项目到Gilab,并编写好.gitlab-ci.yml , GitLab-Runner 自动拉取代码,然后进行Build,编译,单元测 ...

  3. C# RSA加解密和MD5加密

    1.RSA加密 /// <summary> /// 加密处理 /// </summary> /// <param name="content"> ...

  4. 几条shell命令

    windows: route add 158.0.0.0 mask 255.0.0.0 158.137.38.1 metric 3 linux: netstat -apn  查看所有端口使用,可查看端 ...

  5. BZOJ 1001--[BeiJing2006]狼抓兔子(最短路&对偶图)

    1001: [BeiJing2006]狼抓兔子 Time Limit: 15 Sec  Memory Limit: 162 MBSubmit: 29035  Solved: 7604 Descript ...

  6. bootstrap 常用class(不定时更新)

    1,字体居右 text-right 2,字体居中 text-center

  7. Concurrent包工具类使用

    一.读写锁 传统的同步锁就是独占式锁,当线程使用资源时候保持独占,无论读写.当人们发现请求队列(假设)中相邻请求为读-读的时候,阻塞是一种浪费资源的操作.比如公告板,所有路过的人(请求)都是读操作,并 ...

  8. 在android应用程序中启动其他apk程序

    Android 开发有时需要在一个应用中启动另一个应用,比如Launcher加载所有的已安装的程序的列表,当点击图标时可以启动另一个应用. 一般我们知道了另一个应用的包名和MainActivity的名 ...

  9. qwq

    \[{\color{coral}{\texttt{ 邪王真眼是最强的!}}}\] \[{\color{coral}{\texttt{ 爆裂吧现实----}}}\] \[{\color{coral}{\ ...

  10. 【LeetCode】390. 消除游戏

    题目 给定一个从1 到 n 排序的整数列表. 首先,从左到右,从第一个数字开始,每隔一个数字进行删除,直到列表的末尾. 第二步,在剩下的数字中,从右到左,从倒数第一个数字开始,每隔一个数字进行删除,直 ...