Drupal 7 тема не называется?

Я пытался создать шаблон из моей пользовательской формы, сделанной в пользовательском модуле, но мне не удается вызвать .tpl.php

Вот моя функция в моем файле template.php темы (который находится в: drupal / sites / all / themes / atheme):

 function atheme_theme() {
return array(
// Defines the form ID as a theme hook.
'agendize_multistep_form' => array(
// Specifies 'form' as a render element.
'render element' => 'form',
'path' => drupal_get_path('theme', 'atheme') . '/templates',
'template' => 'agendize_multistep_form',
),
);
}

[/ NOEDIT]

Мой идентификатор формы: agendize_multistep_form (я проверял с drupal_set_message)

Файл моего шаблона находится под:

Друпала / сайты / все / темы / atheme / шаблоны / agendize_multistep_form.tpl.php

Я поместил намеренно пустой заголовок, чтобы отобразить пустую форму.
Но у меня все еще есть (даже с очищенным кешем) моя форма со всеми отображаемыми элементами, как будто я никогда не объявлял эту тему переопределенной.

Спасибо за вашу помощь

0

Решение

Я надеюсь, что приведенный ниже код поможет вам.

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 / шаблон / 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 any remaining elements, such as hidden inputs (token, form_id, etc). -->
<?php print drupal_render_children($form); ?>

Пожалуйста, очистите кэш и проверьте.

1

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector