I have a form set up like this:
function mymodule_form_{my_form_id}_alter(&$form, &$form_state, $form_id) {
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => 'Save',
'#ajax' => array(
'wrapper' => 'ajax-node',
'method' => 'replace',
'callback' => 'mymodule_callback',
'effect' => 'fade'
),
'#submit' => array('node_form_submit'),
);
}
And then the callback:
function ajax_complaint_save_callback($form, &$form_state) {
$nid = $form_state['build_info']['args'][0]->nid;
$node = node_load($nid);
return drupal_render(node_view($node));
}
Now this does work sort of, but the node is not rendered correctly. I have some more AJAX stuff on the same page which uses the ajax links api and that produces the node forms correctly. Here are some pictures to demonstrate.
In this picture, one of the links in the table was clicked and the stuff circled with blue was loaded using the links api - this is how it should look.
But if go to the edit tab on the loaded node (which is also loaded up through the ajax links api) then press the save button, I get this:
There's more to this picture, but this is loaded in the same div as the other stuff was - but it seems like it is missing style information, and also the view/edit tabs are missing.
How do I make it load up the node form properly?