# Reset and Retain data in Text Fields on RoR Forms

**URL:** <https://www.ruby-forum.com/t/reset-and-retain-data-in-text-fields-on-ror-forms/109991>\
**Category:** Rails\
**Created:** [July 21, 2007, 12:24am UTC](https://www.ruby-forum.com/t/reset-and-retain-data-in-text-fields-on-ror-forms/109991 "2007-07-21T00:24:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arif](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/74df32/32.png) [@arif](https://www.ruby-forum.com/u/arif)\
**Post date:** [July 21, 2007, 12:24am UTC](https://www.ruby-forum.com/t/reset-and-retain-data-in-text-fields-on-ror-forms/109991/1 "2007-07-21T00:24:42Z")

</div>

Hi,  
I apologize if this appears to be too elementary and answered before.  
I need to reset a text\_field (named as ‘server\_name’) in my controller.  
The relevant controller code is:  
\<%= start\_form\_tag :action =\> ‘search’%\>  
\<%= text\_field :server, :server\_name, :size =\> 15 %\>  
\<%= submit\_tag ‘Search’ %\>  
\<%= end\_form\_tag %\>

Also, I need to retain the values typed by the user in the above text  
field.  
Could anybody help on how to do these?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![arif](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/74df32/32.png) [@arif](https://www.ruby-forum.com/u/arif)\
**Post date:** [July 21, 2007, 12:39am UTC](https://www.ruby-forum.com/t/reset-and-retain-data-in-text-fields-on-ror-forms/109991/2 "2007-07-21T00:39:25Z")

</div>

1. don’t use start\_form\_tag and end\_form\_tag -\> they’ve been  
deprecated. Use form\_tag or form\_for instead.

2. when/how do you want to reset the text field? Do you want to have a  
button that the user can press to reset the text field? If so, you  
can use javascript to do this…

3. what do you mean “retain the values”? Retain them where? Store them  
to a database? Keep the values in the text fields if the user submits  
a form with errors? Please elaborate.

Adam
