Skip to content

Commit

Permalink
[merb-helpers] Use a helper method instead of a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
snusnu committed Oct 15, 2009
1 parent 2c86bef commit c4f4944
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions merb-helpers/lib/merb-helpers/form/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,7 @@ def update_bound_controls(method, attrs, type)

def update_unbound_controls(attrs, type)
if attrs[:name] && !attrs[:id]
# '[' and ']' are illegal in HTML id attributes
attrs.merge!(:id => attrs[:name].to_s.gsub(/(\[|\])/, '_'))
attrs.merge!(:id => valid_xhtml_id(attrs[:name]))
end
case type
when "text", "radio", "password", "hidden", "checkbox", "file"
Expand All @@ -385,6 +384,10 @@ def update_unbound_controls(attrs, type)
super
end

def valid_xhtml_id(candidate)
candidate.to_s.gsub(/(\[|\])/, '_')
end

def radio_group_item(method, attrs)
unless attrs[:id]
attrs.merge!(:id => "#{@name}_#{method}_#{attrs[:value]}")
Expand Down

0 comments on commit c4f4944

Please sign in to comment.