Skip to content

Odaeus/attribute_labels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Attribute Labels
================

Attribute Labels does what it says on the tin. You can specify text for
each attribute that will appear on form labels and validation messages.

If validates_presence_of is set for an attribute an asterisk will be
suffixed to its form label.


Example
=======

class Vehicle < ActiveRecord::Base
  label :wheels => 'Number of wheels',
        :man_auto => 'Manual or automatic?',
        :abs => 'ABS'

  validates_presence_of :wheels
end

Where AR would normally give you: 'Wheels', 'Man auto', 'Abs'

<% form_for(@vehicle) do |f| %>
  <%= f.label :wheels %>
  <%= f.text_field :wheels %>
<% end %>

Will produce:
  Number of wheels*  ______________


Copyright (c) 2008 Andrew France, released under the MIT license.

About

Set custom labels for model attributes in Rails

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages