Advertisement
dvdsantana

Err:SonataAdminBundle y relación manytomany con campos extra

May 14th, 2013
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. class Usuario implements UserInterface, \Serializable
  2. {
  3.     /**
  4.      * @ORM\Column(nullable=true)
  5.      * @ORM\OneToMany(targetEntity="xxx\UsuarioBundle\Entity\LogroUsuario", mappedBy="usuario")
  6.      */
  7.     private $logros;
  8.  
  9.     public function __construct()
  10.     {
  11.         $this->logros = new \Doctrine\Common\Collections\ArrayCollection();
  12.     }
  13. }
  14.  
  15. class LogroUsuario
  16. {
  17.     /**
  18.      * @var integer
  19.      *
  20.      * @ORM\Column(name="id", type="integer")
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue(strategy="AUTO")
  23.      */
  24.     private $id;
  25.  
  26.     /**
  27.      * @var \DateTime
  28.      *
  29.      * @ORM\Column(name="fecha_conseguido", type="datetime")
  30.      */
  31.     private $fecha_conseguido;
  32.  
  33.     /**
  34.      *
  35.      * @ORM\ManyToOne(targetEntity="xxx\UsuarioBundle\Entity\Usuario", inversedBy="logros")
  36.      * @ORM\JoinColumn(name="usuario_id", referencedColumnName="id")
  37.      *
  38.      */
  39.     private $usuario;
  40.  
  41.     /**
  42.      *
  43.      * @ORM\ManyToOne(targetEntity="Logro")
  44.      * @ORM\JoinColumn(name="logro_id", referencedColumnName="id")
  45.      */
  46.     private $logro;
  47. }
  48.  
  49. class UsuarioAdmin extends Admin
  50. {
  51.     protected function configureFormFields(FormMapper $formMapper)
  52.     {
  53.       $formMapper
  54.            ->add('logros', 'entity', array(
  55.                  'class' => 'UsuarioBundle:Logro',
  56.                  'property' => 'nombre',
  57.                  'multiple' => true,
  58.                  'required' => false,))
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement