module LRD::FormBuilder
# pass { :nolabel => true } to replace the label with a spacer
# pass { :required => true } to dispay as a required field # pass { :text => "foo" } to override the label text # pass { :class => 'foo'} to add 'foo' to the CSS class of the <div> # # input_options hash gets passed directly to the input field def labeled_input(form, field, options = {}, input_options = {}) options[:text] = " ".html_safe if options[:nolabel] options.reverse_merge!(:text => nil,:required => false, :nolabel => false) options.merge!(:form => form, :field => field) input_options.reverse_merge!( :size => 30 ) cssclass = "labeled_input" cssclass += " required" if options[:required] cssclass += " #{options[:class]}" if options[:class] unless input = options[:input] input = form.text_field field, input_options end if field.blank? label = (content_tag :label, options[:text]).html_safe else label = (form.label field, options[:text]).html_safe end comment = options[:comment] ? content_tag( :span, { :class => 'comment' } ) { options[:comment] } : "" content_tag(:div, (label + input + comment), { :class => cssclass }).html_safe end
f.labeled_input(stuff, :input_type => :hidden)
f.labeled_input(stuff){ f.hidden_field(stuff) }
Public Instance Methods
labeled_input(method, options = {}, &block)
click to toggle source
# File lib/app/helpers/lrd_form_helper.rb, line 156 def labeled_input(method, options = {}, &block) @template.labeled_input(@object_name, method, objectify_options(options), &block) end
unlabeled_submit(text = nil, options={})
click to toggle source
# File lib/app/helpers/lrd_form_helper.rb, line 159 def unlabeled_submit(text = nil, options={}) @template.unlabeled_submit(text, options) end