2012-03-06 46 views
0

我已經使用在Drupal 6日起模塊爲我定製module.But在Drupal 7,我收到此錯誤無法使用日期模塊在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模塊中找到它。 請讓我知道如果我失去了一些東西。

感謝 一個

回答

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()函數,查看該元素類型的可用選項的完整列表。

+0

謝謝克萊夫我能看到日期彈出 – 2012-03-07 14:05:02