Add block to form (before submit button) I'm having problems placing a block in my form. This is what I have now:

I have a register form and a fb button block. I say the block must be visible only when page is equal to user register page. 

But the problem is that I don't want to have the form and underneath the block. I would like to add the block before the submit button of my form. How can I do this?
You can do something like this:


load the block content manually
control the order of fields withj #weight option


example:

function my_form()
{
  $block = block_load(MODULENAME, BLOCKDELTA);
  $block = _block_render_blocks(array($block));
  $block_build = _block_get_renderable_array($block);

  $form['FIELD_1'] = array(
    ...
    ...
    '#weight' =&gt; 1
  );

  $form['FIELD_2'] = array(
    ...
    ...
    '#weight' =&gt; 2
  );

  $form['FIELD_3'] = array(
    '#prefix' =&gt; '&lt;div class="SOME_CLASS"&gt;',
    '#suffix' =&gt; '&lt;div&gt;',
    '#markup' =&gt; render($block_build),
    '#weight' =&gt; 3
  );

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; 'OK',
    '#weight' =&gt; 4
  );

  return $form;
}


if those forms are from other modules you can alter them with hook_form_alter(&amp;$form, &amp;$form_state, $form_id) function.

example:

function MYMODULE_OR_THEME_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  // dpm($form_id);
  if ('user_register_form' == $form_id) {
    $form['actions']['#weight'] = 50;

    $block = block_load(MODULENAME, BLOCKDELTA);
    $block = _block_render_blocks(array($block));
    $block_build = _block_get_renderable_array($block);

    $form['fb_field'] = array(
      '#prefix' =&gt; '&lt;div class="SOME_CLASS"&gt;',
      '#suffix' =&gt; '&lt;div&gt;',
      '#markup' =&gt; render($block_build),
      '#weight' =&gt; 49
    );
  }
}