delete form-control in form-row symfony/twig

你离开我真会死。 提交于 2021-01-27 19:08:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!