In a preprocess_node
hook, I try to insert a Drupal node_form form in my page. I do it with this function:
function my_module_get_edit_form($selection) {
drupal_add_library('system', 'drupal.ajax');
drupal_add_library('system', 'drupal.form');
$form = drupal_get_form('selection_node_form', $selection);
//here some code to disable (#access = FALSE) unwanted fields and options
$form['actions']['submit'] = array(
'#type' => 'button',
'#value' => 'Update',
'#limit_validation_errors' => array(),
'#ajax' => array(
'callback' => 'smll_selection_ajax_callback',
'wrapper' => 'selection_form'
),
);
return drupal_render($form);
}
The form is rendered properly but when I click my submit button, it always submits the form and forwards me to the node's page, no ajax call.
I tried adding #ajax array onto a select field in the same form ($form['field_application_type']['und']['#ajax']
) but nothing is triggered when I change the select's value. No HTTP request, no Javascript error, nothing.
I tried using drupal_build_form
with a manufactured $form_state
.
I tried creating my form in an another function and calling it with drupal_build_form
.
I tried setting #ajax_processed
to TRUE
.
The HTML id selection_form
exists but, anyway, I never come to the moment the callback function is called.
return "Yipee";
But it is never called.