Rendering form manually When making my ticket-system I want managers to be able to reply to tickets when viewing the ticket. On the page to view any ticket I load my form. Because I want it to be a bit more fancier than just the default 'element under element' style I render each item by item manually.

&lt;?php print drupal_render($form['open']); ?&gt;


Now the problem is, my form doens't work. Clicking on my rendered submit doesn't perform any action.

My guess is that rendering each item manually doesn't include the 'form container'. How should I include is? Or is my style of working completely wrong?
The best way to implement custom rendering of a form would be to use a custom theme hook for the form:

/**
 * Builder function for the ticket form.
 */ 
function MODULE_ticket_form($form, $form_state) {
  // Build the $form array here...

  // Let the theme API knows that this form use it own theme hook.
  $form['#theme'] = 'ticket_form';
  return $form;
}

/**
 * Implements hook_theme().
 */
function MODULE_theme() {
  return array(
    // Custom theme hook for the ticket form.
    'ticket_form' =&gt; array(
      'render element' =&gt; 'form',
    ),
  );
}

/**
 * Default implementation for the ticket_form theme hook. 
 */
function theme_ticket_form($variables) {
  $form =&amp; $variables['form'];

  //Custom rendering of forms elements goes here...
  $output = ...;    

  // Render every other elements (incl. hidden system ones).
  $output .= drupal_render_children($form);
  return $output;
}


Instead of using only a theme function, you can also use a template file. The theme function can also return a render array instead of a string.