symfony/symfony — Issue #3468: Choice List in a Form
Author: umpirsky
Created: 2012-02-28 11:20:24+00:00
State: open

Hi.

Here is my form [ProductType](https://github.com/umpirsky/symfony-standard/blob/f59d47767a07bf1e06d55a2ebff13a13ae6aa199/src/Acme/DemoBundle/Form/ProductType.php) and [this](https://github.com/umpirsky/symfony-standard/blob/f59d47767a07bf1e06d55a2ebff13a13ae6aa199/src/Acme/DemoBundle/Controller/ProductController.php#L51) is how I use it in action.

I expect it to render available categories in choice list, but it renders text field for category, I read the doc, and [this](http://epixa.com/2011/08/create-and-validate-a-choice-list-in-a-symfony-2-form.html) article, and tried the same, but all I get is a text field for category.

It renders available categories in choice list only if I remove [getDefaultOptions()](https://github.com/umpirsky/symfony-standard/blob/f59d47767a07bf1e06d55a2ebff13a13ae6aa199/src/Acme/DemoBundle/Form/ProductType.php#L23) from [ProductType](https://github.com/umpirsky/symfony-standard/blob/f59d47767a07bf1e06d55a2ebff13a13ae6aa199/src/Acme/DemoBundle/Form/ProductType.php) and explicitly pass [Product](https://github.com/umpirsky/symfony-standard/blob/f59d47767a07bf1e06d55a2ebff13a13ae6aa199/src/Acme/DemoBundle/Entity/Product.php) as a second parameter to [$this->createForm()](https://github.com/umpirsky/symfony-standard/blob/f59d47767a07bf1e06d55a2ebff13a13ae6aa199/src/Acme/DemoBundle/Controller/ProductController.php#L53), but I guess that is not the right way to do it.