must be compatible with that of Sonata\AdminBundle\Admin\AdminInterface::validate() error message

You are using sonata and want to validate some fields.
You innocently add the validate function to your Admin file

function validate(ErrorElement $errorElement, $object)
{
}

Then, you get this error :

Fatal error: Declaration of Adin\AdminBundle\Admin\AnnonceAdmin::validate() must be compatible with that of Sonata\AdminBundle\Admin\AdminInterface::validate() in /home/www/arlogis/src/Adin/AdminBundle/Admin/AnnonceAdmin.php on line 251 

You checked to AdminInterface file the declaration is the same.

To fix it, you need to use additionnal namespace :

use Sonata\AdminBundle\Validator\ErrorElement;
use Symfony\Component\Validator\ValidatorInterface;

Leave a Reply