I need to add an additional HTML attribute to each choice of an EntityType field in Symfony 2.7.
Following this guide, I assume that EntityType inherits this feature from ChoiceType. I tried something like the following, but without effect; no mytype attribute gets added to the rendered select options.
$builder->add('customer_email', 'email')
->add('Product', 'entity', array(
'class' => 'MyBundle:Product',
'property' => 'name',
'empty_value' => 'None',
'required' => false,
'choice_attr' => function ($val, $key, $index) {
return array('mytype' => $val->getType());
}))