Render a custom form in a custom template For my site, I have to create a custom form in a custom template. It is not in a custom block, but in a custom tpl-file. I have searched the internet for a solution, but or the form is not shown or the fields are shown, but not in a &lt; form > tag. This way, the submit-button does not work. When I render the fields in a self-written form-tag, the validate function and submit-function don't work. 

Can someone help me?

TPL-File

$form = _odisee_forms($form, $dag, $datum, $uur, $campussen);
$form['infodag'] = form_process_checkboxes($form['infodag']);
$formulier = drupal_get_form('infodagen-block-form');
print '&lt;form id="'.$formulier['#id'].'" accept-charset="UTF-8" method="'.$formulier['#method'].'" action="'.$formulier['#action'].'"&gt;'; 
print drupal_render_children($form); 
//print render($form);
print render($formulier['form_id']);
print render($formulier['form_build_id']);
print render($formulier['form_token']);
print '&lt;/form&gt;';


forms.inc

function _odisee_forms($type, $dag, $datum, $uur, $campussen) {
  $form = array();
  foreach ($campussen as $key =&gt; $campus) {
  $infomoment[] = t($dag[$key])." ".$datum[$key]. " @ " .$campus. " om ".$uur[$key];
  }
  $form['#id'] = 'infodagen-block-form';
  $form['infodag'] = array(
    '#type' =&gt; 'checkboxes',
    '#options' =&gt; $infomoment,
    '#required' =&gt; TRUE,
  );
  $form['voornaam'] = array(
    '#type'  =&gt; 'textfield',
    '#title' =&gt; t('&lt;img src="/sites/all/modules/custom/odisee_forms/images/icon.png" class="icon"&gt;'),
    '#size'  =&gt; 15,
    '#attributes' =&gt; array(
      'placeholder' =&gt; array('Voornaam'),
      'class' =&gt; array('breed')
    ),
    '#required' =&gt; TRUE,  
  ); 
  $form['naam'] = array(
    '#type'  =&gt; 'textfield',
    '#title' =&gt; t('&lt;img src="/sites/all/modules/custom/odisee_forms/images/icon.png" class="icon"&gt;'),
    '#size'  =&gt; 15,
    '#attributes' =&gt; array(
      'placeholder' =&gt; array('Naam'),
      'class' =&gt; array('breed')
    ),
    '#required' =&gt; TRUE,  
  );
  $form['emailadres'] = array(
    '#type' =&gt; 'textfield', 
    '#title' =&gt; t('&lt;img src="/sites/all/modules/custom/odisee_forms/images/arroba-symbol.png" class="icon"&gt;'),
    '#size' =&gt; 20, 
    '#maxlength' =&gt; 128, 
    '#required' =&gt; TRUE,
    '#attributes' =&gt; array(
      'placeholder' =&gt; array('E-mailadres'),
      'class' =&gt; array('breed')
    ),
  );
  $form['submit'] = array(
    '#type'  =&gt; 'submit',
    '#value' =&gt; t('Schrijf in!'),
    '#attributes' =&gt; array('class' =&gt; array('button')),
    '#submit' =&gt; array('_odisee_form_submit'),
    '#validate' =&gt; array('_odisee_form_validate'),
  );
  return $form;
}


function _odisee_forms_validate($form_id, &amp;$form, &amp;$form_state) {
  dpm($form_state, "state");
  dpm($form);
}

function _odisee_forms_submit($form, &amp;$form_state) {
}
You need to render your form in the template. Simply calling drupal_get_form won't suffice. To render the form use following:

drupal_render(drupal_get_form('form_nam'))

You also need to ensure the following:


In your custom form #theme parameter is set to appropriate theme function.


Further the hook_theme implementation is correct.



Refer this link for a working example