1 Replies - 3086 Views - Last Post: 04 September 2007 - 06:48 PM Rate Topic: -----

#1 spullen  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 10
  • View blog
  • Posts: 356
  • Joined: 22-March 07

putting more things onto params

Post icon  Posted 15 June 2007 - 07:45 PM

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 so I can read all of those when I go to the controller,
I can get that to print out so I know it is there. Any suggestions?


EDIT:

I found a solution. You can use hidden_field and have the same parameters as text_field, and then have :value => "something"
<%= hidden_field 'response', 'message_id', :value => params[:id] %>

This post has been edited by Amadeus: 16 June 2007 - 06:44 AM


Is This A Good Question/Topic? 0
  • +

Replies To: putting more things onto params

#2 spullen  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 10
  • View blog
  • Posts: 356
  • Joined: 22-March 07

Re: putting more things onto params

Posted 04 September 2007 - 06:48 PM

O yeah I also found you can do something like params[:somethings][:other] = "something" if you wanted to add radnom things in the controller.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1