Hi all,
I have a problem when I use a ChoiceField with the transformer
CollectionToChoiceTransformer and don't know the best way to fix it.
I got the following warning:
( ! ) Warning: Invalid argument supplied for foreach() in [...]/src/
Symfony/Bundle/DoctrineBundle/Form/ValueTransformer/
CollectionToChoiceTransformer.php on line 82
on ChoiceField creation
I had a look and the problem is the transform method in
CollectionToChoiceTransformer which want an array but null value is
passed:
public function transform($value)
{
$metadata = $this->getOption('em')->getClassMetadata($this-
>getOption('className'));
$reflField = $metadata->getReflectionProperty($metadata-
>identifier[0]);
$ids = array();
foreach ($value AS $object) {
$ids[] = $reflField->getValue($object);
}
return $ids;
}
So, I succeeded to fix it in two different ways:
- Add test in transform method to ensure null value will not being
iterated
- Add a normalization_transformer in my ChoiceField creation which
transform null value in ArrayCollection (Doctrine class)
Before submit a fix, I want to be sure the best way.
Thanks
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en