Created
August 18, 2008 06:20
-
-
Save wycats/5941 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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