【问题标题】:How to add Placeholder on choice list with MDbootstrap and symfony如何使用 MDbootstrap 和 symfony 在选择列表中添加占位符
【发布时间】:2019-04-20 21:50:28
【问题描述】:

基于 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']
            ])

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

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

请问有什么解决办法吗?

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

因为我使用的是 MaterialDesignBootstrap 而不是引导程序,所以我使用了占位符,例如该问题的响应,但不起作用。

【问题讨论】:

标签: javascript twitter-bootstrap symfony symfony4 mdbootstrap


【解决方案1】:
$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',
         ]
        ])

告诉我是否可以

【讨论】:

  • 对不起,同样的问题,可能是 Mdbootstrap 中的错误
  • 你用过吗? // 材质选择初始化 $(document).ready(function() { $('.mdb-select').materialSelect(); });
  • 请检查你的树枝
  • {{ form_row(form.categorie) }}
【解决方案2】:

好的,如果你这样做了

$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',
     ]
    ]);

【讨论】:

  • 同样的问题 :(
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-09-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-14
相关资源
最近更新 更多