2017-09-12 10 views
0

カスタムモジュールで作成したカスタムフォームを作成しようとしましたが、.tpl.phpを呼び出すことができません。Drupal 7テーマが呼び出されていませんか?

私のテーマtemplate.phpファイル(下にあります:drupal /サイト/すべて/テーマ/ 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', 
), 
); 
} 

マイフォームIDは次のとおりです。

のDrupal /サイト/すべて/テーマ:agendize_multistep_form(私はdrupal_set_messageで確認)

は私のテンプレートファイルは、下にあります/atheme/templates/agendize_multistep_form.tpl.php

空白のフォームが表示されるように、私はintentionnalyに空白を入れます。 しかし、私はまだクリアされたキャッシュを持っていますが、私はこのテーマをオーバーライド宣言したことがないかのように、すべての要素が表示されたフォームを持っています。

あなたの助けを借りて

答えて

1

私は以下のコードが役立つことを願っています。

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); ?> 

キャッシュをきれいにチェックしてチェックしてください。

+0

あなたが与えた唯一の違いは、テーマメソッドで与えられたパラメータについてです。私は、キャッシュをクリアした後でも、テーマは適用されていない、これと同じ場所にこれを置く。実際、tpl.phpに何も置かないと、私のコンポーネントが表示されます。 tplが空であるため空白のページを表示する必要があります –

関連する問題