Skip to content

Instantly share code, notes, and snippets.

@wycats
Created August 18, 2008 06:20
Show Gist options
  • Save wycats/5941 to your computer and use it in GitHub Desktop.
Save wycats/5941 to your computer and use it in GitHub Desktop.
def check_box(method_or_attrs = {}, attrs = {})
unless method_or_attrs.is_a?(Hash)
method = method_or_attrs
name = control_name(method)
update_control_fields(method, attrs, "checkbox")
check_box({:name => name}.merge(attrs))
else
attrs = method_or_attrs
end
update_fields(attrs, "checkbox")
if attrs.delete(:boolean)
on, off = attrs.delete(:on), attrs.delete(:off)
hidden_field(:name => attrs[:name], :value => off) <<
self_closing_tag(:input, {:type => "checkbox", :value => on}.merge(attrs))
else
self_closing_tag(:input, {:type => "checkbox"}.merge(attrs))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment