Reputation: 111
For example, I want all my 'DateType' fields to be widget single_text
with format dd/mm/yyyy
. How to set those as the default options for my app?
Upvotes: 1
Views: 31
Reputation: 2598
Create a BaseDateType
class with the following content:
class BaseDateType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'widget' => 'single_text',
'format' => 'dd/mm/yyyy',
]);
}
public function getParent()
{
return DateType::class;
}
}
Then use BaseDateType
in your forms, and you can still override options if you need.
Upvotes: 1