I need to implement form validation depending on submitted data. While data object's invoice property is true then validation_groups array should contain not only 'add' validation but also 'company'.
I've found "Groups based on Submitted Data" chapter in Symfony Docs https://github.com/symfony/symfony-docs/blob/master/book/forms.rst.
The problem is that :
public function getDefaultOptions(array $options)
{
return array(
'data_class' => 'Strict\PublicBundle\Entity\Booking',
'validation_groups' => function(FormInterface $form)
{
return array('booking');
},
);
}
throws this error:
Warning: Illegal offset type in /var/www/vendor/symfony/src/Symfony/Component/Validator/GraphWalker.php line 101 500 Internal Server Error - ErrorException
Any ideas what can be wrong?