Hey there all, I need a bit of help with my website

I'm making a gallery which is public. Users can submit pictures to this public gallery using a simple 'Add Image' button.

Currently, when a user clicks on the 'Add Image' button, a thickbox modal box is generated containing an add image form like:

//Place image.module form
$image_form .= drupal_get_form("image_form");
print $image_form;

This prints the form out as expected, and I can use the functions of the form. The only issue is, when I press submit, it redirects me to the standard Add Content pages (with all fields filled) and I need to press submit on that form in order to submit.

Is there a way to stop my embedded form from going to the normal Image submit form and instead, just create derivatives and add to the database?

Comments

mokargas’s picture

Ok I have submission working on the form, but don't know how to ajax it.

How can I ajax the form so I don't need to leave the page?

mokargas’s picture

Ok I'm trying to use jQuery to submit my form - currently it works without the ajax, but strangely, not with it

Here's what I'm using

$.ajax({
   type: "POST",
   url: "/node/add/image",
   data: "title="+titleVal+"&body="+bodyVal+"&main_image="+mainImageVal+"",
   success: function(msg){
     alert( "Data Saved: " + msg );
   }
 });

can anyone figure out why this may not work - the form appears to submit, but all I get is the following in the address bar

http://localhost/drupal5/gallery?title=ads&files%5Bimage%5D=HHF424.jpg&changed=&body=das&form_token=42d65df99e6a3bf789d625ce52bbd320&form_id=image_node_form&op=Submit
mokargas’s picture

No one's ever made drupal forms submit via ajax I take it?