I have a node add form in a overlay, that is submitted using AJAX.
Is there any way to return node edit form as ajax response once you add the node?. I have tried with drupal_build_form in the custom submit handler, but resulted with error. The code sample as follows:
$form['actions']['submit']['#ajax'] = array(
'callback' => 'mymodule_node_form_js_submit',
'wrapper' => 'my-node-form',
'method' => 'replace',
'effect' => 'fade',
);
function mymodule_node_form_js_submit($form, &$form_state) {
$node = $form_state['node'];
if (isset($node->nid)) {
return drupal_build_form('my_node_form',$node);
}
return $form;
}