【问题标题】:drupal form override theme functiondrupal表单覆盖主题功能
【发布时间】:2010-02-19 10:11:08
【问题描述】:

我创建了一个生成小表单的模块。 我还制作了一个应该为表单设置主题的函数,覆盖标准主题。 但是出于某种原因,它不调用 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;
}

【问题讨论】:

    标签: drupal drupal-fapi hook-menu hook-theme


    【解决方案1】:

    我想你忘了实现 hook_theme。尝试添加:

    function mailinglist_theme() {
      return array(
        'mailinglist_form' => array(
          'arguments' => array('form' => NULL),
        ),
      );
    }
    

    添加此代码后不要忘记刷新您的主题注册表。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-08
      • 1970-01-01
      相关资源
      最近更新 更多