Formtastic: Forms Made Crazy Easy for Rails Developers
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的更多相关文章
- Ruby on Rails 初次冲浪体验
为了更好的阅读体验,欢迎訪问 作者博客原文 Rails is a web application development framework written in the Ruby language. ...
- Ruby On Rails 常用的精品Gem汇总
首先需要注明一点,本文是原创的并不是从其它地方转载.所有的数据是我从 GitHub 和 RubyGems 上码下来的,数据的截取时间就是本文的发布日期. RubyGems 的下载量可以看到在用这个 g ...
- (转)Ruby On Rails 推荐 Gem 列表
作者:尘缘,QQ:130775,来源:http://www.4wei.cn/archives/1002157 PHP的包管理Composer还在刚刚兴起的阶段,Ruby社区已经有很多成熟的Gem了,R ...
- JavaScript资源大全中文版(Awesome最新版)
Awesome系列的JavaScript资源整理.awesome-javascript是sorrycc发起维护的 JS 资源列表,内容包括:包管理器.加载器.测试框架.运行器.QA.MVC框架和库.模 ...
- Top 22 Free Responsive HTML5 Admin & Dashboard Templates 2018
Top 22 Free Responsive HTML5 Admin & Dashboard Templates 2018 May 18, 2018 Alex Ivanovs Website ...
- 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 ...
- Knockout 新版应用开发教程之Observable Arrays
假如你想到侦测和相应一个对象的改变,假如你想要侦测和响应一一组合集的改变,就要用observableArray 在许多场景都是很有用的,比如你要在UI上需要显示/编辑的一个列表数据集合,然后对集合进行 ...
- Git工作流指南:Gitflow工作流 Comparing Workflows
Comparing Workflows The array of possible workflows can make it hard to know where to begin when imp ...
- git workflows
https://www.atlassian.com/git/tutorials/comparing-workflows Comparing Workflows The array of possibl ...
随机推荐
- jQuery中的AJAX的使用
1.运用ajax()方法,比其它如load().get().post()全局性函数它更多地关注实现过程中的细节:首先要了解其参数列表: url: 要求为String类型的参数,(默认为当前页地址)发送 ...
- JavaScript中使用function作为对象键值
JavaScript的键值只能是string或者number,这一点真是返祖现象啊.现在我面临的问题: var funcs = {}; var funcA = function() { }; var ...
- C#基础复习(1) 之 Struct与Class的区别
参考资料 [1] 毛星云[<Effective C#>提炼总结] https://zhuanlan.zhihu.com/p/24553860 [2] <C# 捷径教程> [3] ...
- 关于STM32位带操作随笔
以前在学习STM32时候关注过STM32的位带操作,那时候只是知道位带是啥,用来干嘛用,说句心里话,并没有深入去学习,知其然而不知其所以然.但一直在心中存在疑惑,故今日便仔细看了一下,写下心得供日后参 ...
- [TJOI2013]攻击装置(网络流,最小割)
前言 网络流被hbx吊起来打 Solution 考虑一下这个走法是不是和象棋中马的走法一模一样(废话) 那么显然我每一次移动是走三次,如果将棋盘二分图染色一下,不就是每一次只能走到另一个颜色的吗? 然 ...
- 基于SWOOLE的分布式SOCKET消息服务器架构
消息服务器使用socket,为避免服务器过载,单台只允许500个socket连接,当一台不够的时候,扩充消息服务器是必然,问题来了,如何让链接在不同消息服务器上的用户可以实现消息发送呢? 要实现消息互 ...
- [JavaScript] iframe加载完成事件
//iframe加载完成后,对其子元素进行操作 var iframe = document.getElementById("re-img"); if (iframe.attachE ...
- 【css】——根据div个数显示不同的样式
这里记录面试融众集团的一道题 Q:说可能有1~3个item显示在同一行,而item的个数不一定,如果1个,那这个item占宽100%,2个时每一个50%,3个时每一个33%,用纯CSS实现. A:先贴 ...
- 【wireshark】总体结构
1. 总体结构 wireshark的总体结构如下图所示. 2. 功能模块 模块名 功能 源码子目录 GTK/Qt 处理所有的用户输入/输出(所有的窗口,对话框等等) /ui GTK: /ui/gtk ...
- sublime text3---Emmet:HTML/CSS代码快速编写神器
Emmet的前身是大名鼎鼎的Zen coding,如果你从事Web前端开发的话,对该插件一定不会陌生.它使用仿CSS选择器的语法来生成代码,大大提高了HTML/CSS代码编写的速度,比如下面的演示: ...