Description
I'm upgrading one of my bundles to the new version 3 standard and came across this bug.
Within my FormType, I add child types like so:
$builder->add('type', new SelectType(), array(
'choices' => array_combine($choices, static::$defaultChoices),
'required' => true,
'data' => self::INCLUSIVE,
'options' => array(
'width' => 'auto',
),
));
The documentation for FormBuilder::add
states that the second parameter $type
accepts string|FormTypeInterface
. But, stepping through the code, I see the child is added to the $unresolvedChildren
array. Later when getForm
is called, each of these children are resolved by passing that type to FormFactory::createNamedBuilder
, which expects a string.
I don't know if this is a documentation error or in fact a bug in the code. I would prefer to pass in an instance of the child type since I can construct it accordingly. Using strings and services would be a pain.