Label Helpers plugin

Plugin details

This Rails plugin provides additional form helpers and customization. Initially this includes label helpers, but I intend to add other helpers to assist with forms and accessibility.

Websitehttp://www.eric-stewart.com/blog/articles/2006/01/13/label-me-please Repositoryhttp://svn.eric-stewart.com/pub/rails/plugins/label_helpers/ Author Eric Stewart Tags label LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install http://svn.eric-stewart.com/pub/rails/plugins/label_helpers/

== Usage

  < form action="save_person" method="post">
    <%= label "person", "name", "Name:" %>
    <%= text_field "person", "name", "size" => 20 %>

    < input type="submit" value="Save">
  < /form>


This would produce:

  < form action="save_person" method="post">
    < label for="person[name]">Name:< /label>
    < input type="text" id="person_name" name="person[name]"
      size="20" value="<%= @person.name %>" />

    < input type="submit" value="Save">
  < /form>


Say you had validates_presense_of on person.name. The template output would then be:

  < form action="save_person" method="post">
    < label for="person[name]">Name: cannot be blank
    < div class="fieldWithErrors">< /div>

    < input type="submit" value="Save">
  < /form>


Of course there is a handy tag helper as well to be used in a template as such:

  < form action="save_person" method="post">
    <%= label_tag "person[name]", "Name:"
    <%= text_field "person", "name", "size" => 20 %>

    < input type="submit" value="Save">
  < /form>

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | Back in time (1 older version) | Last edited by: hardway, 10 months ago