【问题标题】:drupal 7 date_popup default value does not displaydrupal 7 date_popup 默认值不显示
【发布时间】:2014-03-04 14:16:11
【问题描述】:

我正在为我的表单使用 drupal 7 date_popup 字段类型:

    $form['departure_date_1']= array(
    '#type' => 'date_popup',
     '#date_format' => 'Y-m-d',
    '#defalut_value'=>date('Y-m-d',strtotime($date_part1)),
);

$date_part1 是字符串:“2014-03-12”,我使用 strtotime 将其转换为日期。我也试过了:

 $form['departure_date_1']= array(
    '#type' => 'date_popup',
     '#date_format' => 'Y-m-d',
    '#defalut_value'=>date('Y-m-d'),
);

或者:

$form['departure_date_1']= array(
    '#type' => 'date_popup',
     '#date_format' => 'Y-m-d',
    '#defalut_value'=>'2014-03-12',
);

它们都不起作用,文件一直是空白的,我搜索了一整天,但仍然找不到问题。

【问题讨论】:

    标签: date drupal-7 drupal-forms


    【解决方案1】:

    最好搭配核心功能

    format_date($date, 'custom', $format)
    

    来源:https://stackoverflow.com/a/16485564/195812

    【讨论】:

      【解决方案2】:

      使用#default_value 代替#defalut_value

      【讨论】:

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