passing hidden field data

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
<p id="disappear"><%= f.collection_select :patient_id,
Patient.find_main, :id, :namer %></p>
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

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.