I have a node form in a block, that is submitted using AJAX.
I've created my own callback, because I'm adding the created node to the page if the submission was successful.
Now, I want to reset the node form to the default values. Any ideas on how to accomplish that?
Update: I've managed to replace the form, by looking at the way node_add() works.
$new_node = (object) array(
'uid' => $user->uid,
'name' => (isset($user->name) ? $user->name : ''),
'type' => 'node_type',
'language' => LANGUAGE_NONE,
);
And then, I'm replacing the entire form with the return value from drupal_render(drupal_get_form('node_form', $new_node));
The form gets replaced as it should be, apart from some ids being different. However, when I submit the new form, I'll get a javascript alert window, with the entire contents of a new page. I can see from the HTML, that it's the page for the node that has been created. I suppose the AJAX callback gets redirected to the new node, but I don't know why.
Any clues?