我用 Symfony2 创建了一个这样的表单:
$builder
->add('days', 'date', array(
'widget' => 'choice',
'format' => 'dd-MM-yyyy',
'pattern' => '{{ day }}-{{ month }}-{{ year }}',
'years' => range(Date('Y'), 2010),
'label' => 'Inactive participants since',
'input' => 'string',
));
但是我想显示一个默认日期,例如今天,所以,当我打印 de form 时,我看到了
02 - 05 - 2012
有什么想法吗?
最佳答案
这适用于日期吗?
$builder
->add('days', 'date', array(
'widget' => 'choice',
'format' => 'dd-MM-yyyy',
'pattern' => '{{ day }}-{{ month }}-{{ year }}',
'years' => range(Date('Y'), 2010),
'label' => 'Inactive participants since',
'input' => 'string',
'data' => '01-01-2001'
));
关于forms - 表单中的默认日期 (symfony2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10410164/