I'm trying to create a templated form including date_popup field in a custom module. There is a very basic example : mkl_variousTest.module ( dependency : date_popup from date API )
<?php
//mkl_variousTest.module
/**
* Implementation of hook_menu()
* @return array
*/
function mkl_variousTest_menu() {
$items = array();
$items['testFormTemplate'] = array(
'title' => t('Test form template'),
'page callback' => 'mkl_variousTest_form_page',
'access callback' => TRUE,
);
return $items;
}
/**
* Implementation of hook_theme($existing, $type, $theme, $path)
* @param array $existing
* @param string $type
* @param string $theme
* @param string $path
* @return array
*/
function mkl_variousTest_theme($existing, $type, $theme, $path) {
$themes = array();
$themes['formPage'] = array(
'template' => 'mkl_variousTest_formPage',
'path' => drupal_get_path('module', 'mkl_variousTest') . '/templates',
'variables' => array(
'form' => drupal_get_form('mkl_variousTest_form'),
),
);
return $themes;
}
/**
* Implementation of hook_form($form, &$formState)
* @param node $node
* @param array $formState
* @return array
*/
function mkl_variousTest_form($node, &$formState) {
$form = array();
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Nom'),
'#lenght' => 60,
'#required' => TRUE,
);
$form['date'] = array(
'#type' => 'date_popup',
'#title' => t('date'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('OK'),
);
return $form;
}
function mkl_variousTest_form_page() {
return theme('formPage');
}
?>
Using this way, drupal run in an infinite loop and return this error :
Fatal error: Maximum function nesting level of '100' reached, aborting!
There is a printScreen :
Next, the same function calls between #19 to #37 are repeated until drupal stop the loop. This append as soon as I have a date_popup field in my form.
So how can I fix it ?
PS : This is my template file mkl_variousTest_formPage.tpl.php :
<p>before</p>
<?php print drupal_render_children($form); ?>
<p>after</p>
date_popup
field? Have you tried removing it? Are you sure it's got to do with the date_popup? What's in yourmkl-variousTest-formPage.tpl.php
template file?