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.