php - Drupal 7 theme not called? -
i tried make template form custom form made in custom module, dont manage call .tpl.php
here function in theme template.php file (which under : drupal/sites/all/themes/atheme) :
function atheme_theme() { return array( // defines form id theme hook. 'agendize_multistep_form' => array( // specifies 'form' render element. 'render element' => 'form', 'path' => drupal_get_path('theme', 'atheme') . '/templates', 'template' => 'agendize_multistep_form', ), ); } my form id : agendize_multistep_form (i checked drupal_set_message)
an template file under:
drupal/sites/all/themes/atheme/templates/agendize_multistep_form.tpl.php
i put intentionnaly blank tpl in order have blank form displayed. still have (even cleared cache) form elements displayed , if never declared theme overriding.
thx help
i hope below code helps you.
atheme/template.php:
function atheme_theme($existing, $type, $theme, $path) { $items['agendize_multistep_form'] = array( 'render element' => 'form', 'template' => 'agendize_multistep_form', 'path' => drupal_get_path('theme', 'atheme') . '/template', ); return $items; } agendize_multistep_form():
function agendize_multistep_form($form, &$form_state) { $form['first_name'] = array( '#type' => 'textfield', '#attributes' => array('placeholder' => t('first name')), ); $form['last_name'] = array( '#type' => 'textfield', '#attributes' => array('placeholder' => t('last name')), ); $form['submit'] = array( '#type' => 'submit', '#value' => 'submit', ); return $form; } atheme/template/agendize_multistep_form.tpl.php:
<div class="agendize-form"> <div class="firstname"> <?php print render($form['first_name']); ?> </div> <div class="lastname"> <?php print render($form['last_name']); ?> </div> <div class="submit"> <?php print render($form['submit']); ?> </div> </div> <!-- render remaining elements, such hidden inputs (token, form_id, etc). --> <?php print drupal_render_children($form); ?> kindly clear cache , have check.
Comments
Post a Comment