Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

allow hash as 2nd argument to select list

  • Loading branch information...
commit 0753cb6fe5769fe1cb6fdfc8e735d2512251c299 1 parent df9bebe
@ahoward authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/dao/form.rb
View
11 lib/dao/form.rb
@@ -396,9 +396,18 @@ def select(*args, &block)
list.each do |pair|
returned = block.call(pair)
+ opts = Map.new
+
case returned
when Array
content, value, selected, *ignored = returned
+
+ if value.is_a?(Hash)
+ map = Map.for(value)
+ value = map.delete(:value)
+ selected = map.delete(:selected)
+ opts.update(map)
+ end
when Hash
content = returned[:content]
value = returned[:value]
@@ -415,7 +424,7 @@ def select(*args, &block)
selected = value.to_s==selected_value.to_s
end
- opts = {:value => value}
+ opts[:value] = value
opts[:selected] = Coerce.boolean(selected) if selected
option_(opts){ content }
end
Please sign in to comment.
Something went wrong with that request. Please try again.