Closed
Description
With this sample of code:
$productsChoices = $this->getDoctrine()->getRepository('AppBundle:Product')->getChoicesGroupByCategory();
dump($productsChoices);
$form = $this->createFormBuilder()
->add('product', 'entity', [
'class' => 'AppBundle\Entity\Product',
'choices' => $productsChoices,
'property' => 'nameWithPrice',
])
->getForm()
;
And an extract of dump($productsChoices);
:
array:23 [▼
"Adresses IP" => array:1 [▼
0 => Product {#3546 ▼
-id: 12
-name: "Adresse IP Failover"
-ref: "xxx"
-price: 42.0
-isRecurrent: true
-category: ProductCategory {#3641 ▶}
-features: PersistentCollection {#3561 ▶}
}
]
"Bande-Passante" => array:3 [▼
0 => Product {#3660 ▼
-id: 65
-name: "Bande passante"
-ref: "xxx"
-price: 42.0
-isRecurrent: true
-category: ProductCategory {#3663 ▶}
-features: PersistentCollection {#3661 ▶}
}
1 => Product {#3668 ▶}
2 => Product {#3670 ▶}
]
"CDN" => array:3 [▼
0 => Product {#3674 ▼
-id: 24
-name: "CDN Statique"
-ref: "xxx"
-price: 42.0
-isRecurrent: true
-category: ProductCategory {#3677 ▶}
-features: PersistentCollection {#3675 ▶}
}
1 => Product {#3681 ▶}
2 => Product {#3684 ▶}
]
Twig rendering:
{{ form(form) }}
I got this rendered select:
<select id="form_product" name="form[product]" class=" form-control">
<optgroup label="Adresses IP">
<option value="18">VPN IpSec - 42.00 €</option>
</optgroup>
<optgroup label="Bande-Passante">
<option value="18">VPN IpSec - 42.00 €</option>
<option value="59">Ajout de disque - 42.00 €</option>
<option value="58">Ajout de RAM - 42.00 €</option>
</optgroup>
<optgroup label="CDN">
<option value="18">VPN IpSec - 42.00 €</option>
<option value="59">Ajout de disque - 42.00 €</option>
<option value="58">Ajout de RAM - 42.00 €</option>
</optgroup>
<!-- ... -->
</select>
For example, first value should not be "VPN IpSec" but "Adresse IP Failover".
This is a BC break and/or regressions because code was not modified and worked like a charm on 2.6
.
Using last dev-master Symfony version:
$ composer info -i | grep symfony/symfony
symfony/symfony 2.7.x-dev e09874b The Symfony PHP framework
Same error on 2.7.0
stable.
Regards