School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,481 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,776 people online right now. Registration is fast and FREE... Join Now!




putting more things onto params

 

putting more things onto params

spullen

15 Jun, 2007 - 06:45 PM
Post #1

D.I.C Regular
Group Icon

Joined: 22 Mar, 2007
Posts: 356



Thanked: 9 times
Dream Kudos: 100
My Contributions
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
CODE

<%= 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"
CODE
<%= hidden_field 'response', 'message_id', :value => params[:id] %>


This post has been edited by Amadeus: 16 Jun, 2007 - 05:44 AM

User is offlineProfile CardPM
+Quote Post


spullen

RE: Putting More Things Onto Params

4 Sep, 2007 - 05:48 PM
Post #2

D.I.C Regular
Group Icon

Joined: 22 Mar, 2007
Posts: 356



Thanked: 9 times
Dream Kudos: 100
My Contributions
O yeah I also found you can do something like params[:somethings][:other] = "something" if you wanted to add radnom things in the controller.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 03:57AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month