Forum: Ruby on Rails Reseting form controls

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
7db3b1680807d393d40260591b4ae5e0?d=identicon&s=25 sa 125 (sa125)
on 2008-12-30 10:39
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 %>
 <%= :available,
     :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

I'm new in rails, so any help will be great.
This topic is locked and can not be replied to.