Domanda

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.

È stato utile?

Soluzione

Better to go with the core function

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

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

Altri suggerimenti

instead of #defalut_value use #default_value

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top