Ajax form in preprocess_node never triggers 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' =&gt; 'button',
    '#value' =&gt; 'Update',
    '#limit_validation_errors' =&gt; array(),
    '#ajax' =&gt; array(
      'callback' =&gt; 'smll_selection_ajax_callback',
      'wrapper' =&gt; '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.
You don't use the correct function for that;

function MYMODULE_form_alter(&amp;$form, &amp;form_state, $form_id) {
  if($form_id == 'selection_node_form' //and same condition you call your function){
    //do your changes here
  }
}


Or use drupal_retrieve_form then you can override the form.
The drupal_get_form call the function drupal_build_form which build the form, you can't override it that way.