2018-07-25 15:41
浏览 29


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.nombre FROM Exppromociones p");
    $productos = $query2->getArrayResult();

The table should look like this:


With the variable $productos I build a form:

   $form = $this->createFormBuilder()
        ->add('productos', 'choice', array('label' => 'Productos',
            'required' => true,
            'choices' => $productos,

And that form results to:

<optgroup label="0">
   <option value="id">93</option>
   <option value="nombre">Espumante Chandon Brut Nature</option>

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>
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题