Here function is overriding on based framework called by name Sonata which is building admin template :
protected function configureFormFields(FormMapper $formMapper){
$formMapper->add('owner', 'sonata_type_model_list',
array(
'class' => 'XYZXBundle:ContestUser',
'btn_add' => false, //Specify a custom label
'btn_list' => 'Search', //which will be translated
'btn_delete' => false, //or hide the button.
'btn_catalogue' => 'SonataNewsBundle', //Custom translation domain for buttons
), array(
'placeholder' => 'No owner selected'
))
}
Object structure:
/**
* @ORM\ManyToOne(targetEntity="XYZ\XBundle\Entity\ContestUser")
* @ORM\JoinColumn(name="owner_id", referencedColumnName="id")
* @var XYZ\XBundle\Entity\ContestUser
*/
protected $owner;
Happens when i tried to insert new row.
Error stacktrace:
Expected argument of type "XYZ\XBundle\Entity\XYZ\XBundle\Entity\ContestUser", "XYZ\XBundle\Entity\ContestUser" given` in vendor\symfony\symfony\src\Symfony\Component\PropertyAccess\PropertyAccessor.php at line 254
UPDATE 1
I tried to use like that below, but still causes the same error.
* @ORM\ManyToOne(targetEntity="\XYZ\XBundle\Entity\ContestUser")
or
* @ORM\ManyToOne(targetEntity="ContestUser")
UPDATE 2
file XYZ\X\Entity\Contest.php
<?php
namespace XYZ\XBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Filesystem\Filesystem;
/**
* XYZ\XBundle\Entity\Contest
*
* @ORM\Table(name="contests")
* @ORM\Entity(repositoryClass="XYZ\XBundle\Entity\ListRepository")
* @ORM\HasLifecycleCallbacks()
*/
class Contest
XYZ\X\Entity\ContestUser.php
<?php
namespace XYZ\XBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\ExecutionContext;
use Symfony\Component\Filesystem\Filesystem;
/**
* @ORM\Entity()
* @ORM\Table(name="contest_users")
*/
class ContestUser extends BaseUser
{
Namespaces are still valid ok, but only with type sonata_type_model_list
causes this error.
targetEntity="ContestUser"
– malcolm