Formative
Formative is an extraction of the custom form builder I used in my last couple of Rails projects. It is the simplest thing that could possibly work for me. YMMV.
I am packaging this as a gem mainly for my personal use. So do not expect this to be any of well-documented, complete or refined.
Usage
I am using Formative together with this initializer to enable inline error messages:
# Show error messages next to form field labels
ActionView::Base.field_error_proc = Proc.new {|html_tag, instance_tag|
if html_tag =~ /type="hidden"/ || !(html_tag =~ /<label/)
html_tag
else
%(<span class="field-with-errors">#{html_tag} <span class="error-message">#{[instance_tag.error_message].flatten.first}</span></span>).html_safe
end
}
Then just use Formative::FormBuilder as your builder -- here is an example form (haml):
= form_for :resource, :builder => Formative::FormBuilder do |f|
fieldset
legend Request Form
= f.text_field :bananas, :unit => 'kg',
:hint => 'Enter the amount of bananas in kg you would like to eat right now'
.controls
= f.submit 'Request', :disable_with => 'Request'
p.cancel= link_to 'Cancel', resource_path(@resource)
The generated markup would look something like this: