Hi, I am new to drupal, and now I've encounter a problem, that is How can i change the range of year of the 'date' field type?
if i write this as follows,
$form['something'] = array(
'#type' => 'date',
'#title' => t('Start Date'),
'#default_value' => array('year' => 2007, 'month' => 2, 'day' => 15),
);
It will display the year field from 1900-2050, but I want to change it from 1990-2015.Dose anyone tell me what i need to do ?
Thanks a lot!

Comments

dymht’s picture

Ok, Now i've fix that.My solution is write a theme for this form item
$form['something'] = array(
'#type' => 'date',
'#title' => t('Start Date'),
'#theme' => 'date_dmy',
'#default_value' => array('year' => 2007, 'month' => 2, 'day' => 15),
);

function theme_date_dmy($form_state) {
$year_range = range(1950, 2015);
$years = array();
foreach($year_range as $year) {
$years[$val] =$val;
}
$form['year']['#options'] =$year;
$output = drupal_render($form);
return $output;

}