我在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
这是我使用它的形式如下。
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模块中找到它。 如果我错过了什么,请告诉我。
由于 甲
答案 0 :(得分:0)
你不需要在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()
函数,了解此元素类型的可用选项的完整列表。