Hi all I''m new to rails an i''m trying to build a step by step form / process to gather data. For example: form one: User enters a 8 digit number the submit button points to form 2. form two: the 8 digit number from form one becomes a hidden field in form 2. The problem I have is that the entire hash from form 1 is showing up in form two rather than just the input data. example: form 1: <h1>Step 1</h1> <%= start_form_tag :action => ''step2'' %> <%= render :partial => ''form1'' %> <%= submit_tag "Register Tag" %> <%= end_form_tag %> Here is the partial (form1): <!--[form:tag]--> <p> <%= text_field ''tag'', ''tag'' %></p> <!--[eoform:tag]--> CONTROLLER: def step1 @tag = Tag.new render :action => ''step1'' end def step2 @newtag = (@params[:tag]) @tag = Tag.new render :action => ''step2'' end FORM 2: ... <input id="tag" name="tag" type="hidden" value="<%= @newtag %>" /></p> RESULT: If I submit 12345678 in form 1 I get "tag12345678" in form 2 FORM 2: Source after Form 1 submit <input id="tag" name="tag" type="hidden" value="tag12345678" /></p> I only want the digits 12345678. -- Posted via http://www.ruby-forum.com/.
Takashi Okamoto
2006-Mar-29 15:06 UTC
[Rails] Help: Input of form 1 to hidden field in form 2?
you''re feeding the whole tag hash into @newtag. try changing in your controller:> CONTROLLER: > def step1 > @tag = Tag.new > render :action => ''step1'' > end > > def step2 > @newtag = (@params[:tag])@newtag = (@params[:tag][:tag])> @tag = Tag.new > render :action => ''step2'' > endmaybe you should change the name of your text_field name to something like tag[value]...tag[tag] is a bit confusing: <%= text_field ''tag'', ''value'' %> -tak.
Seemingly Similar Threads
- simplest way (set of functions) to parse a file
- couting events by subject with "black out" windows
- String manipulation with regexpr, got to be a better way
- Regular expression \ String Extraction help
- NMDS plot and Adonis (PerMANOVA) of community composition with presence absence and relative intensity