From the mailing list, 7 April 2005. WikiGardening and expansion required.
>> So replace it with: >> <input id="virtual_oldemail" name="virtual[oldemail]" size="45" >> type="text" value="<%= @oldemail %>" /> > > Couldn't that be > > <%= text_field "virtual", "oldemail", :size => 45, :value => > @oldemail %> No, unless you have object @virtual with attribute oldemail at hand. text_field implies that it is working on an AR object which is not the case here. Like Tim said, though, it can be <%= text_field_tag "oldemail", @oldemail, :size => 45 %> Then the value would be @params["oldemail"] in the action where the form is submitted (as opposed to @params["virtual"]["oldemail"]). > >> After that the post part of your action should work fine as it is now. >> Except you need to add @oldemail = @params["virtual"]["oldemail"] > > I don't understand this bit. That's _after_ the form is submitted, > right? (If so, OK.) Yes. With "post part of an action" I mean the part inside "when :post". That always means that the form is submitted. If you take a look at Joe's controller, you can see that the action is separated in two parts according to @request.method. :get is when the form page is normally requested. :post gets hit when the form has been submitted to itself (using <form method="post"> of course). You need to add that line to the action because if the form submission (validation) fails, the action probably renders the same form again. In that case you want to prepopulate the field with the value user had already put there. The form view assumes that the value is in @oldemail (not @params["oldemail"]) so you have to assign the correct value to that variable. Hth, //jarkko