Permalink
Browse files

Extract HiddenField

  • Loading branch information...
1 parent 7cc373e commit 6aeb799866ae08a0e8944cc23a48f1616b60d560 @rafaelfranca rafaelfranca committed Jan 16, 2012
@@ -717,7 +717,7 @@ def password_field(object_name, method, options = {})
# hidden_field(:user, :token)
# # => <input type="hidden" id="user_token" name="user[token]" value="#{@user.token}" />
def hidden_field(object_name, method, options = {})
- InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("hidden", options)
+ ActionView::Helpers::Tags::HiddenField.new(object_name, method, self, options).render
end
# Returns a file upload input tag tailored for accessing a specified attribute (identified by +method+) on an object
@@ -5,6 +5,7 @@ module Tags
autoload :Label, 'action_view/helpers/tags/label'
autoload :TextField, 'action_view/helpers/tags/text_field'
autoload :PasswordField, 'action_view/helpers/tags/password_field'
+ autoload :HiddenField, 'action_view/helpers/tags/hidden_field'
end
end
end
@@ -0,0 +1,12 @@
+module ActionView
+ module Helpers
+ module Tags
+ class HiddenField < TextField #:nodoc:
+ def render
+ @options.update(:size => nil)
+ super
+ end
+ end
+ end
+ end
+end

0 comments on commit 6aeb799

Please sign in to comment.