I have a field (EntityType
=> select in the view) in my FormBuilder
that I want it to be in initialized with empty data so I can fill it after that in the view via ajax.
So I have read symfony's documentation about EntityType
and I found the choices
attribute that receives an array of data, so I gave it an empty one 'choices' => array()
and it did the trick.
Now the problem is when I submit the form, symfony don't know anymore the type of the field and give me null
.
This is the builder:
$buidler->add('supplier', EntityType::class, array(
'class' => 'SBC\TiersBundle\Entity\Supplier',
'attr' => array(
'class' => 'uk-select uk-select-supplier'
),
'choices' => array(),
))
As you can see the the type of the field is SBC\TiersBundle\Entity\Supplier
but after submit symfony gives me null !
What should I do to achieve my goal?