Topic: observe_form not working

can anyone help me with this please?? I have a form that uploads a file and its supposed to start uploading as soon as the file_field changes.  It works fine using the submit button but not automatically when the form changes.It doesn't seem to do anything when the form changes.  does observe field work where multipart=>true etc?? here is the code.

<%=form_remote_tag (:url => { :action => :savePicture},
:loading => "'message_text')",
:complete => "Element.hide('message_text')",
:html=>{:id=>"picture_upload_form", :method=>"post", :multipart=>true})%>
  <p><label for="picture_file">Picture</label><br/>
    <%= file_field 'picture', 'file'  %></p>
  <p><input type="submit" name="Save" value="Upload" onclick=""/></p>

<%=observe_form 'picture_upload_form',
:loading => "'message_text')",
:complete => "Element.hide('message_text')",
:failure => "alert('hello')",

Last edited by desi (2007-10-11 09:29:38)

Re: observe_form not working

You could add an :onChange delegate to the picture_file field to submit the form when the file is selected.

<%= file_field 'picture', 'file', :onChange => "this.form.submit();"  %></p>