我想为出生日期做一个出生日期复合下拉列表(即三个下拉列表-一天一个,一个月一个,一年一个)。有用的是,ZF2 内置了这个元素,称为DateSelect
这是我将其添加到表单的方式:
$this->add([
'name' => 'date_of_birth',
'type' => 'DateSelect',
'attributes' => [
'required' => true,
'value' => date('Y-m-d', strtotime('18 years ago')),
],
'options' => [
'label' => 'Date of Birth',
'max_year' => date('Y', strtotime('18 years ago')),
],
]);
要呈现我正在做的表单:
echo $this->form($form);
无论如何,day
元素是以j
格式呈现的(即月份中没有前导零 1
的日期31
)。
如何告诉元素以d
格式呈现日期(即月份中的某天,前导零的 2 位数字 01
)31
?