diff options
author | bparanj <bparanj@yahoo.com> | 2008-12-30 15:00:35 -0800 |
---|---|---|
committer | bparanj <bparanj@yahoo.com> | 2008-12-30 15:00:35 -0800 |
commit | 3dae667d8fd6e959a80d8b6ba825f7b82a36d251 (patch) | |
tree | a12b767b19b5d848fcb7ab1b7953bbbc4c825f99 /actionpack/lib | |
parent | 9c3c88a894cb76a8f753c12fd22f66e3c9d5fe08 (diff) | |
download | rails-3dae667d8fd6e959a80d8b6ba825f7b82a36d251.tar.gz rails-3dae667d8fd6e959a80d8b6ba825f7b82a36d251.tar.bz2 rails-3dae667d8fd6e959a80d8b6ba825f7b82a36d251.zip |
Simple example added for using hidden_field tag used in a form
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_helper.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index a85751c657..094eea1808 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -390,6 +390,14 @@ module ActionView # # hidden_field(:user, :token) # # => <input type="hidden" id="user_token" name="user[token]" value="#{@user.token}" /> + # + # If you have a form object f that is using an object @client: + # <%= f.hidden_field :user_id, :value => current_user.id %> + # # => <input id="client_user_id" name="client[user_id]" type="hidden" value="12345" /> + # + # This passes a hidden variable user_id with the value of current_user.id, it can be accessed in the controller as: + # params[:client][:user_id] + def hidden_field(object_name, method, options = {}) InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("hidden", options) end |