Submit handler is not getting called inside theme function I have created a draggable table and add a submit button below it. I am able to view the submit button but submit handler is not working. Below is the code.

function form_content_reorder($form, &amp;$form_state)
{    
$form = array();
$form['items'] = array();
$form['items']['#tree'] = TRUE;
$form['#theme'] = 'usercontentranking_reorder_form'; 
$form['name'] = array(
 '#type' =&gt; 'item',
 '#markup' =&gt; 'Hello  '.get_genderval($user_data['gender']).$user_data['user_name'],);
$form['submit'] = array(
 '#type' =&gt; 'submit',
 '#value' =&gt; t('Save Preferences'),
 '#submit' =&gt; array('user_content_ranking_save'),);
 return $form;
 }

function usercontentranking_theme($existing, $type, $theme, $path) {
$themes = array(
'usercontentranking_reorder_form' =&gt; array(
  'render element' =&gt; 'element'
),
);
return $themes;
}

function theme_usercontentranking_reorder_form($vars) {
$element = $vars['element'];
drupal_add_tabledrag('draggable_table', 'order', 'sibling', 'weight-group');
$header = array(
 'label' =&gt; t(''), 
 'label2' =&gt; t(''),
 'weight' =&gt; t('Weight'),
 'operations' =&gt; t('Operations'),
); 
$rows = array();

foreach (element_children($element['items']) as $key) {
$row = array();
$row['data'] = array();
$row['data'][] = drupal_render($element['items'][$key]['title']);
$row['data'][] = drupal_render($element['items'][$key]['user_fields']);
$row['data'][] = drupal_render($element['items'][$key]['weight']);
$row['data'][] = drupal_render($element['items'][$key]['operation']);
$row['class'] = array('draggable');
$rows[] = $row;

$themes = drupal_render($element['name']);

$themes .=theme('table', array(
  'header' =&gt; $header, 
  'rows' =&gt; $rows,
  'attributes' =&gt; array('id' =&gt; 'draggable_table'),
));

$themes .= drupal_render($element['submit']);

return $themes;
}

function user_content_ranking_save($form, &amp;$form_state)
{
  print "text";
}


The line 
 $themes .= drupal_render($element['submit']);
able to show up the button but the function user_content_ranking_save is not getting called.
Please help me in this.
It looks like you are declaring your submit button's submit handler correctly. Rather than debugging with print(), try using drupal_set_message() or the Devel module's dpm().

Example with drupal_set_message():

function user_content_ranking_save($form, &amp;$form_state) {
  drupal_set_message('Submit handler was called.');
}


Edit:

Also, if you are constantly refreshing the same form, Drupal may have cached it. Try clearing your cache and see if your submit handler is now being called.

Answer:

Are you sure the whole form is being rendered when using your theme function? It may be that the form is not being validated because the rendered output of the form does not contain the form_id, form_build_id, and/or form_token.