Form added to content in hook_page_build lacks of AJAX I'm adding a form to the footer using hook_page_build because a want to show it using a popup, so when user launches the popup the form appears inmediatly.

The problem is that the form is not AJAX processed: the submit button hasn't the ajax-processed class so AJAX is not working. But if I render the form using hook_menu and drupal_get_form the form has the ajax-processed class and AJAX is working.

Form code fragment:

  $form['message'] = array(
    '#type' =&gt; 'textarea',
    '#title' =&gt; t('Your Personal Message'),
    '#default_value' =&gt; '',
    '#cols' =&gt; 50,
    '#rows' =&gt; 5,
    '#description' =&gt; '',
    '#required' =&gt; TRUE,
  );

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Send Message'),
    '#ajax' =&gt; array(
      'wrapper' =&gt; 'myform-wrp',
      'callback' =&gt; 'myform_ajax_callback',
    ),
  );


Implementation of hook page build: 

function mymodule_page_build(&amp;$page) {

  // Get the current $node
  [...]

  $form = drupal_get_form('mymodule_form', $node);

  $page['footer']['my_form'] = $form;

}


Hook menu that the retrieves a working AJAX form:

function mymodule_menu() {

  $items = array();

  $items['node/%node/mymodule-form'] = array(
    'title' =&gt; 'My form',
    'page callback' =&gt; 'drupal_get_form',
    'page arguments' =&gt; array('mymodule_form', 1),
    'access callback' =&gt; TRUE,
  );

  return $items;
}


I've tested it with hook_page_alter too.

What can be needed to ajaxify this form? I suppose is something related to adding the form too late...
The problem is the element's name: submit. In the rendered page there's another form that have the same button name (submit), so the AJAX layer just ofund one of the buttons but not the two.

To fix this just rename the element's name: 

 $form['myform-submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Send Message'),
    '#ajax' =&gt; array(
      'wrapper' =&gt; 'myform-wrp',
      'callback' =&gt; 'myform_ajax_callback',
    ),
  );