تفوق نموذج دروبال على وظيفة السمة
-
21-09-2019 - |
سؤال
لقد أنشأت وحدة نمطية تولد شكل صغير. لقد قدمت أيضًا وظيفة يجب أن تُظهر النموذج ، مما أدى إلى تجاوز السمة القياسية. لكن تشكيل بعض الأسباب لا تسمي وظيفة السمة. هل أنسى شيئا؟
function mailinglist_menu() {
$items['mailinglist'] = array(
'title' => t('Beheer mailinglist'),
'page callback' => 'mailinglist_overzicht',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
function mailinglist_overzicht() {
return drupal_get_form('mailinglist_form');
}
function mailinglist_form($form_state) {
$form['to'] = array(
'#type' => 'fieldset',
'#title' => t('Aan'),
'#tree' => TRUE,
);
$form['to']['functies'] = array(
'#type' => 'checkboxes',
'#title' => t('Functies'),
'#options' => mailinglist_getFuncties(),
'#description' => t('Selecteer de functies die je wilt mailen.'),
);
return $form;
}
function theme_mailinglist_form($form) {
$output .= '<div class="foo" style="background-color: #000;">sdfsdfsdfdfs';
$output = drupal_render($form['to']['functies']);
$output .= '<div class="bar">';
$output .= '</div></div>';
$output .= drupal_render($form);
return $output;
}
المحلول
أعتقد أنك نسيت تنفيذ Hook_Theme. حاول إضافة هذا:
function mailinglist_theme() {
return array(
'mailinglist_form' => array(
'arguments' => array('form' => NULL),
),
);
}
لا تنس تحديث سجل السمة بعد إضافة هذا الرمز.
لا تنتمي إلى StackOverflow