문제

I am using drupal 7 date_popup field type for my form:

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

$date_part1 is string:"2014-03-12", i use strtotime to convert it to date. i also tried:

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

Or:

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

none of them works, the filed is blank all the time, i searched the whole day, but still can not find the problem.

도움이 되었습니까?

해결책

Better to go with the core function

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

source: https://stackoverflow.com/a/16485564/195812

다른 팁

instead of #defalut_value use #default_value

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top