-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels
Description
Hello,
I get the message:
"Expected argument of type "array or (\Traversable and \ArrayAccess)", "string" given"
in vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php at line 110
if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)');
}
during the execution of this code:
$form = $this->createFormBuilder([], ['csrf_protection' => false])
->add('collectionField', 'collection', ['type' => 'text', 'constraints' => [new Type('array')]])
->add('integerField', 'integer', ['constraints' => [new Type('integer')]])
->getForm();
$form->submit(['collectionField' => 'error', 'integerField' => 'error']);
This is because i pass string data to "collectionField" field.
But when i pass array to "integerField":
$form->submit(['collectionField' => [], 'integerField' => []]);
i get normal message "This value is not valid.".
I think behaviour should be the same. Or maybe i missed something. Thx