drupal表单覆盖主题功能
我创建了一个生成小表单的模块。 我还创建了一个应该以表单为主题的函数,覆盖标准主题。 但由于某种原因它没有调用 theme_ 函数。我是不是忘记了什么?
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;
}
i created a module that generates a small form.
I also made a function that should theme the form, overriding the standard theme.
But form some reason it doesn't call the theme_ function. Am i forgetting something?
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你忘记实现 hook_theme。尝试添加此代码:
添加此代码后不要忘记刷新主题注册表。
I think you forgot to implement hook_theme. Try adding this:
Don't forget to refresh your theme registry after adding this code.