Skip to content

Instantly share code, notes, and snippets.

@x37v
Created March 9, 2011 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save x37v/862742 to your computer and use it in GitHub Desktop.
Save x37v/862742 to your computer and use it in GitHub Desktop.
labeled field wrapper
def labeled_field_wrapper(res, name, f = nil, label_text = nil, &blk)
classes = 'field'
classes << ' field_with_errors' if any_errors(res, name)
label_text ||= name.to_s.capitalize
content_tag(:div, {:class => classes}) do
if f
f.label(name, label_text)
else
label_tag(name, label_text)
end << capture(&blk)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment