Unable to add a submit button to a drupal Block I am adding a submit button (in the callback function 'clearbutton_submit()') - when I click on the button - nothing happens.

What am I doing wrong here?

function cacheclearbutton_block_info() {

$blocks['cacheclearbutton_uppercase'] = array(
// info: The name of the block.
'info' =&gt; t('CacheClear Button Block'),
'region' =&gt; 'sidebar_first',
'status' =&gt; 1,
);

return $blocks;
}


/**
* Implements hook_block_view().
*
* This hook generates the contents of the blocks themselves.
*/
function cacheclearbutton_block_view($delta = '') {
//The $delta parameter tells us which block is being requested.
switch ($delta) {
case 'cacheclearbutton_uppercase':
  $block['subject'] = t("uppercase this please");
  $block['content'] = block_content();
}
return $block;
}

function block_content() {

$block_contents = array();

$block_contents['clearbutton'] = array(
    '#type'         =&gt; 'button',
    '#value'        =&gt; 'Clear Cache by Module',
    '#submit'       =&gt; array('clearbutton_submit'),
);

return $block_contents;
}

function clearbutton_submit($form, &amp;$form_state) {
    cache_clear_all();
    drupal_set_message(t('Setting a message from the submit handler'));
}
A small change needed as below


  
  Key was to chnage the type from button to submit
  But I guess making a separate function to get the form will be better
  


function block_content() {

  //calling the form in the block
  $block_contents = drupal_get_form('_cacheclearbutton_clear_cache_form');

  return $block_contents;
}

// A separate function to return the form to clear the cache
function _cacheclearbutton_clear_cache_form() {
  $form = array();
  $form['clearbutton'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; 'Clear Cache by Module Test',
    '#submit' =&gt; array('clearbutton_submit'),
  );
  return $form;
}

function clearbutton_submit($form, &amp;$form_state) {
  cache_clear_all();
  drupal_set_message(t('Setting a message from the submit handler'));
}