forked from glenngillen/semantic_form_builder
A custom builder (and some helper methods) for creating consistent and accessible forms in rails
unders/semantic-form-builder
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
== Semantic Form Builder Semantic Form Builder is a customer FormBuilder for use in Rails, aiming to give accessible, consistent, forms with the ultimate of DRY. No more defining labels, worrying about formatting, etc. Let the default form_for tag take care of all the hassles for you For an example of what it looks like check: http://rubypond.com/articles/2008/07/16/sexy-forms-in-rails/ == Installation 1. Grab the latest files from git://github.com/rubypond/semantic-form-builder.git 2. Move forms.css into /public/stylesheets in your Rails app 3. Move semantic_form_helper into /app/helpers and add the following to application.rb helper :semantic_form 4. Move sematnic_form_builder into somewhere accessible to Rails (I typically stick with /lib) 5. If you wish to use the builder to replace the default for all forms (which is great for consistency) then add the following into an initializer ActionView::Base.default_form_builder = SemanticFormBuilder Otherwise pass the builder in as the :builder parameter for form_for 6. Be sure to include forms.css in your layout == Usage Continue using form_for and the tag helpers within it as you did before and it should work fine. There has been a few additional tags added for convenience sake. They are: - submit_and_cancel - radio_button_group - check_box_group More documentation on their usage to come, in the interim check out or the http://rubypond.com/articles/2008/07/16/sexy-forms-in-rails/ following example: <% form_for @document do |f| field_set_tag "Form Details" do %> <%= f.date_select :date, :required => true, :help => "date the something happened" %> <%= f.text_field :number, :required => true, :help => "the reference number for this thing" %> <%= f.select :external_id, [["Choose an option...",""]] + @externals.map{|c| [c.name, c.id]}, :required => true, :label => "options", :help => "select something from the list" %> <%= check_box_tag_group "document[other_items][]", @others.map{|u| { :value => u.id, :label => u.description }}, :label => "including these?", :help => "tick the whatever boxes are appropriate for this thing" %> <%= f.text_field :name, :help => "what was Willis talkin' about?" %> <%= f.check_box :list, :label => "mailing list", :help => "can we send you a bunch of spam?" %> <%= f.submit_and_cancel("save", "cancel") %> <% end %>
About
A custom builder (and some helper methods) for creating consistent and accessible forms in rails
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- Ruby 100.0%