Reputation: 6042
I want to build a select input element from the following data:
$nameQuery = $em->createQuery('SELECT p.id, p.name FROM MyBundle:Person');
$names = $nameQuery->getResults();
Where each option is:
<select>
<option value="{{ p.id }}">{{ p.name }}</option>
.
.
.
</select>
I just don't know how to do it with Symfony2's built-in form types. Please assist.
Upvotes: 0
Views: 93
Reputation: 42799
Use form Builder, In form builder, use this
$builder->add('type', 'entity', array(
'class' => 'MyBundle:Person',
'property' => 'name'
));
Upvotes: 2