简体   繁体   中英

SonataMediaBundle Type error when trying to delete the link with media

i have project that uses sonataAdmin and sonataMedia when i tried to delete the image using the check box provided by the bundle click to see image

i get this error :

Type error: Argument 1 passed to BackBundle\\Entity\\reference::setMedia() must implement interface Sonata\\MediaBundle\\Model\\MediaInterface, null given, called in /home/hichem/PhpstormProjects/sifastProject/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php on line 591

it appears exactly here:

Stack Trace

in src/BackBundle/Entity/reference.php at line 69  -
        /**
         * @param MediaInterface $media
         */
        public function setMedia(MediaInterface $media)
        {
            $this->media = $media;
        }

from what i've understand(or at least think so)the setter can't set the value with null if any one know what's the problem please help

Because you have no selected file I think that this will help you:

/**
 * @param MediaInterface $media
 */
public function setMedia(MediaInterface $media = null)
{
    $this->media = $media;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM