问题
When i create this builder
$builder
->add('categorie', EntityType::class, [
// This field shows all the categories
'class' => Categorie::class,
'mapped' => false,
'multiple' => true,
'attr' => ['class' => 'mdb-select']
])
and when i do form_row(form.name)
i see class has value 'form-control' automaticaly, but me i'm use MDBootstrap and i want to set only mdb-select
回答1:
It is caused by one of the default form themes of Symfony, I think by default currently it's the bootstrap 4 theme.
To get rid of that class across the whole app you can change the default form theme, e.g. to form div layout:
# config/packages/twig.yaml
twig:
form_themes: ['form_div_layout.html.twig']
# ...
The documentation also describes how to remove the class in smaller scope.
回答2:
you have to change default theme layout of form or you can create your own custom layout.
来源:https://stackoverflow.com/questions/55616813/delete-form-control-in-form-row-symfony-twig