# Passing hidden field data

**URL:** <https://www.ruby-forum.com/t/passing-hidden-field-data/181820>\
**Category:** Rails\
**Created:** [January 18, 2010, 10:01pm UTC](https://www.ruby-forum.com/t/passing-hidden-field-data/181820 "2010-01-18T22:01:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [January 18, 2010, 10:01pm UTC](https://www.ruby-forum.com/t/passing-hidden-field-data/181820/1 "2010-01-18T22:01:45Z")

</div>

Hi Gurus,

I had a form with a collection

\<%= f.collection\_select :patient\_id, Patient.find\_main, :id, :namer %\>

Where the user selected the :patient\_id. I’ve now reconfigured the  
rails app so that the controller for this form is passed :patient\_id  
in the params hash. I no longer want the user to see this selection,  
but I need to update :patient\_id in the model.

I first just made it disappear with

\<%= f.collection\_select :patient\_id, Patient.find\_main, :id, :namer %\>

where #disappear { display: none; }

But that seemed inelegant. I found hidden\_field and hidden\_field\_tag  
in the rails docs, but can’t seem to get the right syntax. For  
example,

\<%= hidden\_field\_tag :patient\_id, :patient\_id %\>

Is not updating :patient\_id in the model.

Can someone give guidance on the proper usage of hidden\_field/  
hidden\_field\_tag, or if I’m totally off base, what I should be putting  
into the form to hide this transaction?

Many TIA,  
Craig

---

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [January 18, 2010, 10:09pm UTC](https://www.ruby-forum.com/t/passing-hidden-field-data/181820/2 "2010-01-18T22:09:56Z")

</div>

You seem to be pretty close. Have you used a tool like Firebug to  
inspect  
the value of the hidden field?

You’re probably looking for this:

\<%= f.hidden\_field :patient\_id, :value =\> @patient\_id %\>

with @patient\_id being set to whatever value you’d like it to be updated  
to.
