Symfony Forms: HTML5 datalist

前端 未结 4 1930
甜味超标
甜味超标 2020-12-06 14:41

How can be implemented HTML5 datalist with values from the database (Doctrine)?

Purpose: replace selects with many options to inputs with autocompletion.

4条回答
  •  囚心锁ツ
    2020-12-06 15:08

    In your formType :

    ->add('commerciaux', TextType::class,
                [
                    'label'     => 'Apporteur d\'affaire*',
                    'attr'      =>
                        [
                            'placeholder'   => 'Apporteur d\'affaire',
                            'list'          => 'bieres'           
                        ]
                ]
            )
    

    In your View :

                        {{ form_row(formulaire.commerciaux) }}
                        
                            
    

提交回复
热议问题