我收到这样的信息:
类型"array or (\Traversable and \ArrayAccess)“、"string”的预期参数给定
在执行此代码期间:
$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']);这是因为我将字符串数据传递给"collectionField“字段。
但是,当我将数组传递给“integerField”时:
$form->submit(['collectionField' => [], 'integerField' => []]);我收到一条普通的消息:“此值无效。”
我认为行为应该是一样的。当然,我可以做一些工作,并找到一些解决方案,但我想知道这是一个bug,或我是否遗漏了什么。
发布于 2015-06-28 20:12:18
好的。我自己回答我的问题。这是一个bug,将在最近的Symfony版本中修复。https://github.com/symfony/symfony/pull/13851
https://stackoverflow.com/questions/30969121
复制相似问题