Drupal load form with ajax callback in Bootstrap modal I need to load a form into a 'bootstrap modal dialog' which will submit data via ajax callback to callback function.

The form display properly when the modal dialog is launched:

&lt;a data-toggle='modal' href='?q=document/share' data-target='#Modalshare' class='ModalTrigger'&gt;
 &lt;div class='' style='float:right;'&gt;&lt;span class=''&gt;&lt;span title='' class='glyphicon glyphicon-share-alt'&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;a/&gt;


The menu 'document/share call the function 'modal_share()' that display the modal content

&lt;div&gt;...
content
...&lt;div&gt;


Within this function modal_share(), a form is called for render:

function modal_share($fid) {

$f = drupal_get_form('modal_share_form',$fid);
....
....
echo &lt;div&gt; .... ".drupal_render($f) .".....&lt;/div&gt;

}


So far so good and the modal is correctly output with the form 'modal_share_form' as per below structure:

function modal_share_form($form,&amp;$form_state,$fid) {
form['share_list'] = array(
  '#type' =&gt; 'select',
  '#multiple' =&gt; TRUE,
  '#options' =&gt; $option ,
  '#title' =&gt; t(""),
  '#description' =&gt; "",
  '#required' =&gt; false,
  '#default_value' =&gt; $default

);

$form['share'] = array (
        '#type' =&gt; 'button',
        '#value' =&gt; "&lt;span class='glyphicon glyphicon-share-alt'&gt;&lt;/span&gt;&lt;span id=''&gt; ".t('record')."&lt;/span&gt;",
        '#ajax' =&gt; array(
          'callback' =&gt; "modal_share_form_submit", 
          'wrapper' =&gt; 'shareMessage',
          'effect' =&gt; 'fade',
          'method'=&gt;'html'
        ),

        '#id' =&gt; 'modalsharebutton',
);
return $form;
}


Now the problem is the the #ajax function in the button is not rendered by drupal as it should.

the html rendering is:

&lt;button id="modalsharebutton" class="btn btn-primary form-submit" type="button" value="&lt;span class='glyphicon glyphicon-share-alt'&gt;&lt;/span&gt;&lt;span id=''&gt;record&lt;/span&gt;" name="op"&gt;


without the "ajax-processed" class attached

The thing is that if I load the form on a main page ajax function is rendered properly.

So my conclusion is that when building the form for modal, it is not going through the proper ajax build process...

But I can't see the solution.

Thanks for help.
I solved this issue differently by adding '#attribute' with event...

$form['share'] = array(
        '#type' =&gt; 'button',
        '#value' =&gt; "&lt;span class='glyphicon glyphicon-share-alt'&gt;&lt;/span&gt;&lt;span id=''&gt; " . t('Record') . "&lt;/span&gt;",
        '#ajax' =&gt; array(
          'callback' =&gt; "modal_share_form_submit", 
          'wrapper' =&gt; 'shareMessage',
          'effect' =&gt; 'fade',
          'method' =&gt; 'html'
        ),

        '#id' =&gt; 'modalsharebutton',
        '#attributes' =&gt; array('onclick' =&gt; "share_submit($fid);"),

);


Thank you.