From a query I'm trying to personalize the choice field.
this is how I get the content of the select:
$em = $this->getDoctrine()->getManager();
$query2 = $em->createQuery("SELECT p.id,p.nombre FROM Exppromociones p");
$productos = $query2->getArrayResult();
The table should look like this:
{"id":93,"nombre":"Bucket"},
{"id":152,"nombre":"Spoon"},
{"id":142,"nombre":"Fork"}
With the variable $productos I build a form:
$form = $this->createFormBuilder()
->add('productos', 'choice', array('label' => 'Productos',
'required' => true,
'choices' => $productos,
))
->getForm();
And that form results to:
<optgroup label="0">
<option value="id">93</option>
<option value="nombre">Espumante Chandon Brut Nature</option>
</optgroup>
I want the choices field to have the value equal to the id and the innerHTML equal to nombre, like this:
<option value=93>Bucket</option>