Skip to content

Instantly share code, notes, and snippets.

@swalberg
Created November 20, 2011 20:28
Show Gist options
  • Save swalberg/1380843 to your computer and use it in GitHub Desktop.
Save swalberg/1380843 to your computer and use it in GitHub Desktop.
class LocalFormBuilder < ActionView::Helpers::FormBuilder
def label(method, text = nil, options = {})
#Check to see if text for this label has been supplied and humanize the field name if not.
text = text || method.to_s.humanize
#Get a reference to the model object
#Add any additional text that might be needed on the label
text += " <span class=\"text\">#{h options[:description]}</span>".html_safe if options[:description]
text += "<span class=\"required\">*</span>".html_safe if options[:required]
#Finally hand off to super to deal with the display of the label
super(method, text, options)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment