Default value in dropdown <select> (symfony)

376 Views Asked by At

I have this code in the form:

$formShipping->add('shippingType', EntityType::class, array('mapped' => false, 'required' => true,'placeholder' => 'Select a shipping method', 'label' => 'Shipping Method', 'class' => 'BackendBundle\Entity\Shipping', 'choice_label' => 'shipdesc',
                'query_builder' => function (EntityRepository $er) {
                    return $er->createQueryBuilder('s')
                        ->where('s.active = :active')
                        ->orderBy('s.shipdesc', 'ASC')
                        ->setParameter('active', true);
                }, 'attr' => array('class' => 'form-control')));

And this code in twig:

{{ form_row(form.shippingType, {value: "1" })}}

But the result is this:

enter image description here

I review with the inspector:

enter image description here

What is the problem??

0

There are 0 best solutions below