Results table with form select for filtering I have a page set up via a custom module, which contains some data rendered in a table, not using views. I didn't use views because it requires some various calculations that views calc couldn't do.

The table works fine, however, I would like to add a dropdown above the table, so that is has the equivalent of exposed filters like you would see in views.

The trouble is, i haven't had any luck in rendering a form (for the filter widget) in the same page callback as the table. 

Below is the code i have up to this point. I figured this would be a common use case and this information must exist somewhere, but i haven't had any luck in finding an answer to this.

&lt;?php
function mymodule_reports_menu() {
  $items = array();
  $items['people'] = array(
    'title' =&gt; 'Members',
    'page callback' =&gt; 'mymodule_reports_page',
    'access arguments' =&gt; array('access content'),
    'weight' =&gt; 1,
  );
  $items['people/fees-by-month-paid'] = array(
    'title' =&gt; 'Members by Card Number',
    'page callback' =&gt; 'mymodule_fees_by_month_paid',
    'access arguments' =&gt; array('access statistics'),
    'weight' =&gt; 1,
  );
  $items['people/fees-by-card-number'] = array(
    'title' =&gt; 'Members by Card Number',
    'page callback' =&gt; 'mymodule_fees_by_card_number',
    'access arguments' =&gt; array('access statistics'),
    'weight' =&gt; 1,
  );
  return $items;
}

function mymodule_fees_by_card_number_form($form_state) {

  $form = array();

  $form['year'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; t('Year'),
    '#description' =&gt; t('Toggle the Year'),
    '#options' =&gt; array(
      '2015' =&gt; t('2015'),
      '2014' =&gt; t('2014'),
    ),
    '#required' =&gt; TRUE,
  );

  $form['buttons']['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Submit'),
    '#submit' =&gt; array('mymodule_fees_by_card_number'),
    '#validate' =&gt; array(),
  );
  return $form;
}

function mymodule_fees_by_card_number($form_state) {

  // parameter that i will be setting up as the widget
  $year = '2015';


  $output = drupal_get_form('mymodule_fees_by_card_number_form');



  $members = array();

  $members = mymodule_get_membership_by_year($year);

  foreach($members as $key =&gt; $row) {
    $card_number[$key] = $row['card_number'];
    $name[$key] = $row['name'];
  }

  array_multisort($card_number, SORT_ASC, $name, SORT_ASC, $members);

  $yearly_sum = 0;

  $header = array('Card Number', 'Name', 'Paid');
  $rows = array();

  foreach($members as $member) {
    $rows[] = array($member['card_number'], $member['name'], $member['paid']);

    $yearly_sum += $member['paid'];

  }
  $rows[] = array('', '', 'Total:  $' . $yearly_sum);
  $output .= theme('table', array('header' =&gt; $header, 'rows' =&gt; $rows));

  return $output;
}
I don't see a render function anywhere after you create the form. If you didn't exclude it on purpose, after creating the form, it has to be rendered and printed.

in your function you call drupal_get_form()


  Return value
  
  The form array.


and later on you add to that with theme()


  Return value
  
  An HTML string representing the themed output.


it looks like you're trying to put together an array and string in the same variable. You need to either render the form first into a string and then add them together, or include the theme data into the form array and render it later on.