0

I'm picking information from the database in to a dropdown and here it

-------------------
id     | username
-------------------
10     | llj
12     | AFS

How can I obtain this:

<option value="10">llj</option>
<option value="12">AFS</option>

in symfony2

->add('supervisor','entity', array(
          'class' => 'AdminBundle:supervisor',
          'expanded' => false,
          'multiple' => false,
          'placeholder'=>'',

          'empty_value' => null
            ))
Andrea
  • 11,801
  • 17
  • 65
  • 72
Lamin L. Janneh
  • 85
  • 1
  • 1
  • 6
  • You can see this post. http://stackoverflow.com/questions/11999745/how-to-set-up-default-value-in-symfony2-select-box-with-data-from-database – Freenando Aug 06 '15 at 08:17
  • I'm finally able to achieve it in this way on post request 'class' => 'AdminBundle:supervisor', this is send and as object so I can grap the ID which is the option value and send it to the controller $see=$form->getData()->getSupervisor()->getStaffID(); $entity->setColumnValue($see); that particular colum will get the ID instead of the text I hope this will help – Lamin L. Janneh Aug 06 '15 at 16:55

0 Answers0