A full-featured form builder for Rails.
= Informant
Informant is a full-featured form builder for Ruby on Rails (works with Rails 3) which promotes a simple syntax that keeps your views clean. Everything about a field (label, description, error display, etc) is encapsulated in a single method call. Examples and general information are below; please read the {API documentation}[http://rdoc.info/projects/alexreisner/informant] for more complete/detailed information.
== 1. Install
=== a. Rails 3
Install either as a plugin:
rails plugin install git://github.com/alexreisner/informant.git
or as a gem:
config.gem “informant”
bundle install
=== b. Rails 2
As a plugin:
script/plugin install git://github.com/alexreisner/informant.git -r rails_2
== 2. Configure
If you like you can set one of the Informant builders to be your application-wide default by adding something like this to your ApplicationHelper:
ActionView::Base.default_form_builder = Informant::Standard
However, this is not necessary. You can use choose your builder on a form-by-form basis with the :builder option to form_for. The available builders are:
Informant::Standard
Informant::Table
Informant::Simple
== 3. Use
As an example, this view code:
<% form_for @car, :builder => Informant::Standard do |f| %>
<% f.field_set “Details” do %>
<%= f.text_field :name,
:required => true,
:description => "Something Italian, please." %>
<%= f.select :manufacturer,
%w[Ascari Ferrari Lamborghini Pagani] %>
<%= f.integer_select :wheels,
:label => "Number of wheels",
:first => 2, :last => 4 %>
<%= f.text_area :description %>
<%= f.submit %>
<% end %>
<% end %>
renders HTML like this (assuming the @car is a new record):
Note that the field label is inferred from the name if left blank, and the submit button (unless specified) says “Create” if the record is new, “Update” otherwise. There are other field options too. For a complete list please generate the API docs (cd vendor/plugins/informant; rake rdoc) or read them {online}[http://rdoc.info/projects/alexreisner/informant].
== Available Field Types
Currently the following field methods are available:
Please see the inline documentation for arguments to each method.
== To-Do List
Copyright © 2009 Alex Reisner, released under the MIT license