# Observer\_field - select form

**URL:** <https://www.ruby-forum.com/t/observer-field-select-form/105827>\
**Category:** Rails\
**Created:** [June 3, 2007, 2:26pm UTC](https://www.ruby-forum.com/t/observer-field-select-form/105827 "2007-06-03T14:26:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a3d4f5/32.png) [@chil](https://www.ruby-forum.com/u/chil)\
**Post date:** [June 3, 2007, 2:26pm UTC](https://www.ruby-forum.com/t/observer-field-select-form/105827/1 "2007-06-03T14:26:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![chil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a3d4f5/32.png) [@chil](https://www.ruby-forum.com/u/chil)\
**Post date:** [June 5, 2007, 1:51pm UTC](https://www.ruby-forum.com/t/observer-field-select-form/105827/2 "2007-06-05T13:51:30Z")

</div>

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
