Hidden fields

Similar (but different) to another thread called ‘accessing post array’,
I have some records that I need sent via an array but I don’t want to
use a text field but rather a hidden field because I don’t want them
tampered with.

Simplifying my form quite a bit…

<% form_for :supptrans, @supptrans, :url => { :action =>
“print_checks” } do |form| %>

... ... <%= form.hidden_field :paid_invoices, {:value => check_due.id} %> <%= text_field 'check_number', 'check_number', :size => '8' %> <%= submit_tag 'Print Checks' %> <% end %>

where I need the form to submit the starting check number but I also
need the check_due.id in an array so I know which checks are going to be
printed.

this
<%= form.hidden_field :paid_invoices, {:value => check_due.id} %>
is only the latest attempt but I have tried many things including…
<%= hidden_field :paid_invoices, “paid_invoices[]”, {:value =>
check_due.id} %>

but none of them will give me an array of ‘paid_invoices’ that I will be
able to parse later similar to
<%= check_box_tag ‘paid_invoices’, ‘paid_invoices[]’, false %>
would give me

Is there a way to popular an array of ‘hidden_field’ elements for
posting?

Craig


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

<%=h (check_due.supplier.suppname) %> <%=h (check_due.suppreference) %>

Craig W. wrote:

… because I don’t want them tampered with.

Then keep that info server-side.

On Tue, 2009-09-15 at 02:21 +0200, Ar Chron wrote:

Craig W. wrote:

… because I don’t want them tampered with.

Then keep that info server-side.


not sure what you mean by this.

do you mean put them into the session?

do you mean put them into a temporary storage table, perhaps identified
by the session?

I ended up using hidden_field_tag just like I had to use check_box_tag
to accomplish this by the way but I do need persistence of these arrays
through several screens and I have to keep posting them and assigning
them for each screen and perhaps there is a better way.

Craig


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

You could go with active_record_store for your session data.

Check out ActionController::Base at http://api.rubyonrails.org/