Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 82e71e8904
Fetching contributors…

Cannot retrieve contributors at this time

91 lines (57 sloc) 2.347 kb

Formulate

Rails form builder with flexible markup and styles.

Formulate consists of a custom form builder, which builds on top of the default form builder in Rails, and a Sass stylesheet to provide some level of stylistic normalization.

Haml Requirement

Formulate's FormBuilder relies on some helper methods provided by Haml, so it will only work when used within Haml templates.

Installation

Add this line to your application's Gemfile:

gem 'formulate'

If you want to use the Formulate's #form_for helper by default, an engine is provided that will override Rails' helper:

gem 'formulate', require: 'formulate/engine'

And then execute:

$ bundle

Or install it yourself as:

$ gem install formulate

Usage

Formulate provides a helper module that can be included in your Rails controllers. You can also load the helper in your ApplicationController to use it across your whole app.

class ApplicationController < ActionController::Base
  helper Formulate::FormHelper
end

Formulate doesn't clobber any of the built-in form builder methods, so your forms should continue to work without modification, giving you the ability to selectively begin using Formulate in your applications where you see fit.

If you're using the engine, the form builder will be used automatically whenever the #form_for helper is called, so you don't need to do anything special to start using it.

Styles

If you'd like to use Formulate's stylesheet, you'll need to import it into a Sass file like app/assets/stylesheets/forms.css.sass:

@import formulate

Formulate's styles are all scoped under the selector form.formulate, so they shouldn't clobber anything in your own applications. Basically, this just loads a stripped down version of normalize.css with only the parts relevant to forms. It also specifies a handful of styles to improve the vertical rhythm of the elements generated by the form builder.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Copyright

Copyright © 2012 Tyler Hunt. See LICENSE for details.

Jump to Line
Something went wrong with that request. Please try again.