I am new to symfony. Trying to create an add and edit form with it. When I tried to add a select box in which the choice data is populated from database, but the select box shows only id as the value and name of option list
$form = $this->createFormBuilder($defaultData)
->add('category_id', ChoiceType::class, array(
'label' => 'Category',
'choices' => array(
$category)))
This is my controller portion
<label for="exampleInputEmail1"> Category</label>
{{ form_widget(form.category_id, {'attr' : { 'class':'form-control'}}) }}
</div>
my output is
<option value="id">id</option>
Please help me to display name too
<option value="id">Name</option>