【问题标题】:Unable to use Date module in Drupal 7无法在 Drupal 7 中使用日期模块
【发布时间】:2012-03-06 16:48:06
【问题描述】:

我使用 Drupal 6 中的日期模块作为我的自定义模块。但在 Drupal 7 中,我收到此错误

Fatal error: Call to undefined function date_popup_load() in C:\xampp\htdocs\widgetcorp\sites\all\modules\freeway\freeway.admin.inc on line 164 

这是iam使用它的形式如下。

function create_freeway_project (){
  $node = node_load(arg(1));
  $form = array();
  date_popup_load();

  $form['title'] = array(
  '#type' => 'textfield',
  '#title' => t('Project Description'),
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
);

  $form['custRef'] = array(
  '#type' => 'textfield',
  '#title' => t('Customer Reference'),
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
);

  $form['poRef'] = array(
  '#type' => 'textfield',
  '#title' => t('PO Reference'),
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
);


  $form['splinst'] = array(
  '#type' => 'textarea',
  '#title' => t('Special Instructions'),
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
);


  $form['strtdate'] = array(
  '#type' => 'date_popup',
  '#title' => t('Delivery Date'),
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
);


  $form['enddate'] = array(
  '#type' => 'date_popup',
  '#title' => t('End Date'),
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
);


   $form['create_project_btn'] = array(
    '#type' => 'submit',
    '#value' => 'Create Freeway Project',
  );


   return $form;

}

是否要添加 Jquery_UI 模块?我没有在 Drupal 7 的 Date 模块中找到它。 如果我遗漏了什么,请告诉我。

谢谢 一个

【问题讨论】:

    标签: date drupal-7 drupal-modules


    【解决方案1】:

    您无需自己在 Drupal 7 中进行任何设置,就这么简单:

    $form['strtdate'] = array(
      '#type' => 'date_popup',
      '#title' => t('Delivery Date'),
      '#size' => 60,
      '#maxlength' => 128,
      '#required' => TRUE,
      '#date_format' => 'd/m/Y H:i' // With this format you'll get a date popup box AND a time widget. Obviously you can change this to whatever you need.
    );
    

    日期模块将处理添加所需的 JS。

    查看date_popup_element_info() 函数以获取此元素类型可用选项的完整列表。

    【讨论】:

    • 感谢 Clive,我可以看到日期弹出窗口
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多