-1

基于 MDB 的此文档: https ://mdbootstrap.com/docs/jquery/forms/select/

我创建了这个表格

 public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('categorie', EntityType::class, [
            // This field shows all the categories
            'class'    => Categorie::class,
            'Placeholder' => 'Select choice',
            'mapped' => false,
            'multiple' => true,
            'attr' => ['class' => 'mdb-select']
            ])

就像我编码的一样,我想在占位符中看到“选择选择”,但这就是图片中的结果:

在此处输入图像描述

我的问题是我直接看到类类别的结果,但首先我需要看到占位符!

请问有什么解决办法吗?

PS:我的问题与此不重复: How to add placeholder on input in Symfony 4 form?

因为我使用的是 MaterialDesignBootstrap 而不是引导程序,所以我使用了占位符,就像那个问题的回答一样,但不起作用。

4

2 回答 2

0
$builder
        ->add('categorie', EntityType::class, [
        // This field shows all the categories
        'class'    => Categorie::class,
        'placeholder' => 'Select choice',
        'mapped' => false,
        'multiple' => true,
        'required' => false,
        'attr' => [
            'class' => 'mdb-select',
            'placeholder' => 'test',
         ]
        ])

告诉我是否可以

于 2019-04-21T15:39:21.717 回答
0

好的,如果你这样做

$builder
    ->add('categorie', EntityType::class, [
    // This field shows all the categories
    'label' => 'test for categories',
    'class'    => Categorie::class,
    'placeholder' => 'Select choice',
    'mapped' => false,
    'multiple' => true,
    'required' => false,
    'attr' => [
        'class' => 'mdb-select',
     ],
    'label_attr' => [
        'class' => 'mdb-main-label',
     ]
    ]);
于 2019-04-22T07:44:09.633 回答