bml / form-theme-bundle
此组件允许在表单类型类中定义表单主题。
2.0.0
2021-05-04 10:47 UTC
Requires
- symfony/form: ^5.2
- symfony/twig-bridge: ^5.2
- symfony/twig-bundle: ^5.2
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-04 18:06:36 UTC
README
表单主题组件允许在 FormType 类中定义表单主题。
有合并请求实现了此功能,等待审查: symfony/symfony#23990
安装
composer require bml/form-theme-bundle
- 如果你没有使用 symfony flex,请将
new Bml\FormThemeBundle\BmlFormThemeBundle()
添加到AppKernel.php
使用
要定义表单类型主题,为表单定义 theme
选项。例如在类型类中
class YourType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('field') [...] } public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ 'theme' => 'app/form/my_type_theme.html.twig' ]); } }
当你调用 createView()
在你的表单上时,此组件将在后台调用相当于 {% form_theme form 'app/form/my_type_theme.html.twig' %}
的操作。