Observer_field - select form


#1

I want to load a form when a “select form” is changed. I have done this
but it doesn’t work( i do not have an error but nothing change when i
change the select list):

in the view:
<% form_tag :action => ‘update’, :id => @cour do %>

Choissisez le type de votre article:
<%= select :cour, :type_article, {"cours"=>"c", "exercice"=>"ex"},:include_blank=>true %>

<%= observe_field ‘type_article’,
:update => “formulaire”,
:url=>{:action=>‘generation_form’},
:with=>"‘type_article=’ + escape(value)",
%>

-

<%= submit_tag ‘Edit’ %>
<% end %>

In the controller:
def generation_form
type_article = params[:type_article]
if type_article == “ex”
render :partial => “formex”
else
render :partial => “formart”
end
end

the partial _formex:
(formualaire exo)

Contenu
<%= text_area 'cour', 'content' %>

thanks


#2

I found my mistake: wrong name of field.
=> <%= observe_field ‘cour_type_article’, instead of <%= observe_field
‘type_article’,

But I still have two problems with the result:
-The form is updated when the mouse is over a type of document and would
like to updated it when the user clic on the field.
-Without AJAX in “edit mode” the field were filled by the data already
saved. Now the fields are blank when the form is updated by AJAX.

Thanks