On Wednesday 21 February 2007, Shauna wrote:
Can’t connect to the website of the repository. Is this plugin
defunct?
I have no idea, but a local copy 
See below for label_helper.rb
HTH,
Michael
http://www.eric-stewart.com/blog/articles/2006/01/13/label-me-please
Helpers for generating label tags for inputs
Includes some support for accessibility techniques
module ActionView
module Helpers
module FormHelper
# Returns a label tag tailored for describing a specified
attribute (identified by +method+) on an object
# assigned to the template (identified by +object+). Additional
options on the tag can be passed as a
# hash with +options+.
#
# Examples (call, result):
# label(“post”, “title”, “Post Title”, :class => “foo”)
# Post Title
def label(object, method, label_text = nil, options = {})
label_text ||= “#{method.titleize}:”
InstanceTag.new(object, method, self).to_label_tag(label_text,
options)
end
end
module FormTagHelper
# Creates a standard label for a field.
#
# Options:
# * <tt>:disabled</tt> - If set to true, the user will not be able
to use this input.
# * :hide_errors - If set to false, the label will append
validation errors for the object
# it is a label for
# A hash of standard HTML options for the tag.
def label_tag(for_id, value = nil, options = {})
options.stringify_keys!
if !options.has_key?(‘for’)
options[‘for’] = for_id
end
content_tag(“label”, value, options)
end
end
class InstanceTag #:nodoc:
def to_label_tag(label_text, options = {})
error_string = ""
options["for"] ||= "#{tag_id}"
if options.has_key?('hide_errors')
options.delete('hide_errors')
else
error_string = " <em>#{error_message}</em>"
end
content_tag "label", "#{label_text}#{error_string}", options
end
# This new error_wrapping method prevents a label that is being
generated
# for an object/field from being wrapped by an error div. Only
the input
# tag itself should be wrapped.
alias_method :original_error_wrapping, :error_wrapping
def error_wrapping(html_tag, has_error)
if ['label'].detect { |tag| html_tag.starts_with?("<#{tag}") }
return html_tag
end
original_error_wrapping html_tag, has_error
end
end
end
end
–
Michael S.
mailto:[email protected]
http://www.schuerig.de/michael/