diff --git a/lib/better_form/builder.rb b/lib/better_form/builder.rb index 2428794..c40e54c 100644 --- a/lib/better_form/builder.rb +++ b/lib/better_form/builder.rb @@ -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 = {}) diff --git a/lib/better_form/view_helper.rb b/lib/better_form/view_helper.rb index 289832e..68fbbf1 100644 --- a/lib/better_form/view_helper.rb +++ b/lib/better_form/view_helper.rb @@ -77,6 +77,11 @@ def better_form_stylesheet color: #666; } + span.better_described_field { + color: #999; + font-size: 0.7em; + } + EOT return css end