class Merb::Helpers::Form::Builder::Form
Public Instance Methods
label(contents, attrs = {})
click to toggle source
# File lib/merb-helpers/form/builder.rb, line 301 def label(contents, attrs = {}) if contents if contents.is_a?(Hash) label_attrs = contents contents = label_attrs.delete(:title) else label_attrs = attrs end tag(:label, contents, label_attrs) else "" end end
submit(value, attrs = {})
click to toggle source
Calls superclass method
Merb::Helpers::Form::Builder::Base#submit
# File lib/merb-helpers/form/builder.rb, line 367 def submit(value, attrs = {}) unbound_label(attrs) + super end
unbound_check_box(attrs = {})
click to toggle source
Calls superclass method
Merb::Helpers::Form::Builder::Base#unbound_check_box
# File lib/merb-helpers/form/builder.rb, line 340 def unbound_check_box(attrs = {}) label_text = unbound_label(attrs) super + label_text end
unbound_label(attrs = {})
click to toggle source
# File lib/merb-helpers/form/builder.rb, line 323 def unbound_label(attrs = {}) if attrs[:id] label_attrs = {:for => attrs[:id]} elsif attrs[:name] label_attrs = {:for => attrs[:name]} else label_attrs = {} end label_option = attrs.delete(:label) if label_option.is_a? Hash label(label_attrs.merge(label_option)) else label(label_option, label_attrs) end end
unbound_select(attrs = {})
click to toggle source
Calls superclass method
Merb::Helpers::Form::Builder::Base#unbound_select
# File lib/merb-helpers/form/builder.rb, line 355 def unbound_select(attrs = {}) unbound_label(attrs) + super end
unbound_text_area(contents, attrs = {})
click to toggle source
Calls superclass method
Merb::Helpers::Form::Builder::Base#unbound_text_area
# File lib/merb-helpers/form/builder.rb, line 359 def unbound_text_area(contents, attrs = {}) unbound_label(attrs) + super end
Private Instance Methods
radio_group_item(method, attrs)
click to toggle source
Calls superclass method
Merb::Helpers::Form::Builder::Base#radio_group_item
# File lib/merb-helpers/form/builder.rb, line 393 def radio_group_item(method, attrs) unless attrs[:id] attrs.merge!(:id => "#{@name}_#{method}_#{attrs[:value]}") end attrs.merge!(:label => attrs[:label] || attrs[:value]) super end
update_bound_controls(method, attrs, type)
click to toggle source
Calls superclass method
Merb::Helpers::Form::Builder::Base#update_bound_controls
# File lib/merb-helpers/form/builder.rb, line 373 def update_bound_controls(method, attrs, type) attrs.merge!(:id => "#{@name}_#{method}") unless attrs[:id] super end
update_unbound_controls(attrs, type)
click to toggle source
Calls superclass method
Merb::Helpers::Form::Builder::Base#update_unbound_controls
# File lib/merb-helpers/form/builder.rb, line 378 def update_unbound_controls(attrs, type) if attrs[:name] && !attrs[:id] attrs.merge!(:id => valid_xhtml_id(attrs[:name])) end case type when "text", "radio", "password", "hidden", "checkbox", "file" add_css_class(attrs, type) end super end
valid_xhtml_id(candidate)
click to toggle source
# File lib/merb-helpers/form/builder.rb, line 389 def valid_xhtml_id(candidate) candidate.to_s.gsub(/(\[|\])/, '_') end