Skip to content

Commit

Permalink
Added :description => text option to text_field. Styled span.better_d…
Browse files Browse the repository at this point in the history
…escribed_field
  • Loading branch information
nfm committed Feb 12, 2010
1 parent 5743e84 commit 7799a09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/better_form/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def text_field(method, options = {})
options[:value] = ''
end

(label ||= '') + InstanceTag.new(@object_name, method, self, options.delete(:object)).to_input_field_tag("text", options) + (required_span ||= '') + tag('br')
if description = options.delete(:description)
description_span = content_tag_string(:span, description, { :class => 'better_described_field' }) + tag('br')
end

(label ||= '') + InstanceTag.new(@object_name, method, self, options.delete(:object)).to_input_field_tag("text", options) + (required_span ||= '') + tag('br') + (description_span ||= '')
end

def submit(value = '', options = {})
Expand Down
5 changes: 5 additions & 0 deletions lib/better_form/view_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ def better_form_stylesheet
color: #666;
}
span.better_described_field {
color: #999;
font-size: 0.7em;
}
EOT
return css
end
Expand Down

0 comments on commit 7799a09

Please sign in to comment.