# Clearing form fields for a popup

**URL:** <https://www.ruby-forum.com/t/clearing-form-fields-for-a-popup/154171>\
**Category:** Rails\
**Created:** [November 26, 2008, 4:01am UTC](https://www.ruby-forum.com/t/clearing-form-fields-for-a-popup/154171 "2008-11-26T04:01:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [November 26, 2008, 4:01am UTC](https://www.ruby-forum.com/t/clearing-form-fields-for-a-popup/154171/1 "2008-11-26T04:01:45Z")

</div>

I am using prototype to create modal popups for my login and register  
pages, but the fields are populating with the data from certain  
variables. For example, I have a show page that finds a user like  
so:

@user = User.find(params[:id])

and my form uses:  
\<% form\_for :user, :url =\> users\_path do |f| -%\>

so it is populating the form with the data from @user. Should I  
rename the @user variable, or is there a way to avoid the populating  
of the form?

Thanks for any help.

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [November 26, 2008, 3:13pm UTC](https://www.ruby-forum.com/t/clearing-form-fields-for-a-popup/154171/2 "2008-11-26T15:13:17Z")

</div>

Hi David,

David wrote:

> so it is populating the form with the data from @user. Should I  
> rename the @user variable, or is there a way to avoid the populating  
> of the form?

You should be doing the find in the controller and calling the new  
method to  
return a new, empty object or the edit method to return an existing  
object.

HTH,  
Bill
