Symfony2's Form Factory is throwing a warning on an array_replace(). How can I resolve this warning?
I'm getting the following error on Symfony2:
Warning: array_replace() [function.array-replace]: Argument #1 is not an array in /home/rackelas/public_html/dev/Symfony/vendor/symfony/src/Symfony/Component/Form/FormFactory.php line 236
after adding the following to Acme/Bundle/Form/Type/ContactType.php for validation:
public function getDefaultOptions(array $options)
{
$collectionConstraint = new Collection(array(
'name' => new MinLength(5),
'email' => new Email(array('message' => 'Invalid email address')),
));
$options['validation_constraint'] = $collectionConstraint;
}
source: http://symfony.com/doc/current/book/forms.html#using-a-form-without-a-class
Any help in the 开发者_如何学运维right direction would be appreciated.
Try adding a return $options;
to your getDefaultOptions method.
What you are receiving is not an error, it is a warning.
The warning states that the function is looking for an array, but you are passing it a non-array variable.
So FormFactory.php on line 236 is calling array_replace()
with an argument that is not an array. That is where you should be looking to resolve this problem.
精彩评论