Forum: Ruby on Rails adding things to params in a form

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C0e90ce6f3a7f04fae1a497a9eb0822c?d=identicon&s=25 Scott Pullen (dark-omen)
on 2007-06-16 04:41
I have a form and I am trying to get it to add another parameter without
entering it in a field.
I have the form partial _form.rhtml

<%= error_messages_for 'response' %>

<!--[form:response]-->
<p><label for="response_title">Title</label><br/>
<%= text_field 'response', 'title'  %></p>

<p><label for="response_body">Body</label><br/>
<%= text_area 'response', 'body'  %></p>

<p><label for="response_user">User</label><br/>
<%= text_field 'response', 'user'  %></p>

<p><label for="response_date">Date</label><br/>
<%= datetime_select 'response', 'date'  %></p>
<%= params[:id]%>
<!--[eoform:response]-->

when it goes the controller it passes all the params as
params[:response], but I want to add that params[:id] that I passed in,
I can get that to print out so I know it is there. Any suggestions?
1c908e01ccdcf5ea8a8c202f68900cda?d=identicon&s=25 Ringo (Guest)
on 2007-06-16 05:31
Maybe you could try,
<%= hidden_field 'response', 'putyournamehere', :value => 'anyvalue'%>
C0e90ce6f3a7f04fae1a497a9eb0822c?d=identicon&s=25 Scott Pullen (dark-omen)
on 2007-06-16 05:45
awesome, that was exactly what I was looking for. Thanks.
2b891e820c238ded365d035771603f21?d=identicon&s=25 Bill Walton (Guest)
on 2007-06-16 17:21
(Received via mailing list)
Hi Scott,

Scott Pullen wrote:

> I have a form and I am trying to get it to add another
> parameter without entering it in a field.

hidden_field_tag might be what you're looking for.

hth,
Bill
This topic is locked and can not be replied to.