Ruby on Rails

One of the interesting things about working with the built-in conventions in Rails is the way it gets me thinking about what other conventions I can come up with to make things even easier.

FormStyleHelper

FormStyleHelper is a Rails helper module that overrides the standard form helpers in order to add helpful CSS classes to your form elements for easier styling. Now you can more easily differentiate between input fields and buttons, radio buttons and checkboxes, and everything else. All standard form helpers are supported.

Usage

Install form_style_helper.rb in your Rails application's helpers directory (app/helpers/) and include it at the top of your main ApplicationHelper:

include FormStyleHelper

This makes it available to all views in your application. Now just continue using your form helper methods as usual and the CSS classes will automatically be added to each element. So now this:

<%= text_field_tag "name" %>

Will give you this:

<input class="text_field" id="name" name="name" type="text" />

FormStyleHelper is released under the terms of the MIT License and is free to use and redistribute for any purpose.

Download FormStyleHelper now.

Please get in touch if you have any problems, questions, or comments.