# Reseting form controls

**URL:** <https://www.ruby-forum.com/t/reseting-form-controls/156580>\
**Category:** Rails\
**Created:** [December 30, 2008, 10:39am UTC](https://www.ruby-forum.com/t/reseting-form-controls/156580 "2008-12-30T10:39:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sa125](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b4bc9f/32.png) [@sa125](https://www.ruby-forum.com/u/sa125)\
**Post date:** [December 30, 2008, 10:39am UTC](https://www.ruby-forum.com/t/reseting-form-controls/156580/1 "2008-12-30T10:39:27Z")

</div>

How would I reset the controls on a form? I have a few text fields and  
selection lists, and I want them cleared (text fields) or restored to  
the top value (the :prompt in the select). I tried the code below with  
render :update.

the form is in the view:

\<% form\_for :item, :html =\> { :id =\> ‘items\_form’ } do |f| %\>  
\<%= f.text\_field :name %\>  
\<%= f.select :available,  
[[‘YES’,‘true’],[‘NO’,‘false’]],  
:prompt =\> ‘–Available?–’ %\>

\<%= link\_to\_remote ‘reset’,  
:update =\> ‘items\_list’,  
:url =\> { :action =\> ‘reset\_form’ } %\>

\<% end %\>

the action is in the controller:

def reset\_form  
render :update =\> do |page|  
page[‘items\_form’].reset # this, um, doesn’t work  
end  
end

I’m new in rails, so any help will be great.
