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.
Scott P. (Guest)
on 2007-06-16 06: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?
Ringo (Guest)
on 2007-06-16 07:31
Maybe you could try,
<%= hidden_field 'response', 'putyournamehere', :value => 'anyvalue'%>
Scott P. (Guest)
on 2007-06-16 07:45
awesome, that was exactly what I was looking for. Thanks.
Bill W. (Guest)
on 2007-06-16 19:21
(Received via mailing list)
Hi Scott,

Scott P. 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.