Example for credit card expiration date:
$builder->add('expirationDate', 'date', array(
'label' => 'Expiration date',
'widget' => 'choice',
'empty_value' => array('year' => 'Year', 'month' => 'Month', 'day' => 'Day'),
'format' => 'dd-MM-yyyy',
'input' => 'string',
'data' => date('Y-m-d'),
'years' => range(date('Y'), date('Y') + 10),
));
Then you must render this field manually.
Your form's twig template:
{{ form_row(form.expirationDate, {'date_pattern': '<span style="display: none;">{{ day }}</span> {{ month }} <span class="delim">/</span> {{ year }}'}) }}
Overriding date_pattern
will hide day select. You will get month / year format.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…