Tengo este formulario:
Código PHP:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('dateStart','genemu_jquerydate',array('required' => true, 'widget' => 'single_text'))
->add('dateFinish','genemu_jquerydate',array('required' => true, 'widget' => 'single_text'))
->add('image', 'genemu_jqueryimage', array(
'configs' => array(
'auto' => true,
'multiple' => false
)))
->add('items', 'genemu_jqueryselect2_entity', array(
'class' => 'Acme\sampleBundle\Entity\Item',
'property' => 'name',
'configs' => array(
'multiple' => true
)
)
)
;
}
Se genera correctamente pero al ir a guardar me ocurre esto:
Código:
Neither the property "items" nor one of the methods "addItem()"/"removeItem()", "setItems()", "items()", "__set()" or "__call()" exist and have public access in class "Acme\sampleBundle\Entity\Draw".
Mi clase de Draw es esta:
Código PHP:
<?php
namespace AcmesampleBundleEntity;
use DoctrineORMMapping as ORM;
use SymfonyComponentValidatorConstraints as Assert;
/**
* Draw
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="acme\sampleBundle\Entity\DrawRepository")
*/
class Draw
{
public function __construct() {
$this->items = new DoctrineCommonCollectionsArrayCollection();
}
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToMany(targetEntity="Acme\sampleBundle\Entity\Item")
* @ORM\JoinTable(name="draw_item",
* joinColumns={@ORM\JoinColumn(name="draw_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="item_id", referencedColumnName="id")}
* )
* @Assert\NotBlank()
**/
private $items;
/**
* @ORM\ManyToOne(targetEntity="Acme\sampleBundle\Entity\User", inversedBy="drawsWins")
* @ORM\JoinColumn(name="user_winner_id", referencedColumnName="id")
**/
private $winner;
/**
* @var \DateTime
*
* @ORM\Column(name="dateStart", type="datetime")
* @Assert\NotBlank()
*/
private $dateStart;
/**
* @var \DateTime
*
* @ORM\Column(name="dateFinish", type="datetime")
* @Assert\NotBlank()
*/
private $dateFinish;
/**
* @var string
*
* @ORM\Column(name="image", type="text")
**/
private $image;
/**
* @var string
*
* @ORM\Column(name="description", type="text")
*/
private $description = '';
/**
* @var string
*
* @ORM\Column(name="state", type="string", length=1)
*/
private $state = 0;
/**
* @ORM\ManyToOne(targetEntity="Acme\sampleBundle\Entity\User")
* @ORM\JoinColumn(name="user_maker_id", referencedColumnName="id")
**/
private $maker;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set dateStart
*
* @param \DateTime $dateStart
*
* @return Draw
*/
public function setDateStart($dateStart)
{
$this->dateStart = $dateStart;
return $this;
}
/**
* Get dateStart
*
* @return \DateTime
*/
public function getDateStart()
{
return $this->dateStart;
}
/**
* Set dateFinish
*
* @param \DateTime $dateFinish
*
* @return Draw
*/
public function setDateFinish($dateFinish)
{
$this->dateFinish = $dateFinish;
return $this;
}
/**
* Get dateFinish
*
* @return \DateTime
*/
public function getDateFinish()
{
return $this->dateFinish;
}
/**
* Set image
*
* @param string $image
*
* @return Draw
*/
public function setImage($image)
{
$this->image = $image;
return $this;
}
/**
* Get image
*
* @return string
*/
public function getImage()
{
return $this->image;
}
/**
* Set description
*
* @param string $description
*
* @return Draw
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set state
*
* @param string $state
*
* @return Draw
*/
public function setState($state)
{
$this->state = $state;
return $this;
}
/**
* Get state
*
* @return string
*/
public function getState()
{
return $this->state;
}
/**
* Add item
*
* @param \Acme\sampleBundle\Entity\Item $item
*
* @return Draw
*/
public function addItem(AcmesampleBundleEntityItem $item)
{
$this->items[] = $item;
return $this;
}
/**
* Remove item
*
* @param \Acme\sampleBundle\Entity\Item $item
*/
public function removeItem(AcmesampleBundleEntityItem $item)
{
$this->items->removeElement($item);
}
/**
* Get items
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getItems()
{
return $this->items;
}
/**
* Set winner
*
* @param \Acme\sampleBundle\Entity\User $winner
*
* @return Draw
*/
public function setWinner(AcmesampleBundleEntityUser $winner = null)
{
$this->winner = $winner;
return $this;
}
/**
* Get winner
*
* @return \Acme\sampleBundle\Entity\User
*/
public function getWinner()
{
return $this->winner;
}
/**
* Set maker
*
* @param \Acme\sampleBundle\Entity\User $maker
*
* @return Draw
*/
public function setMaker(AcmesampleBundleEntityUser $maker = null)
{
$this->maker = $maker;
return $this;
}
/**
* Get maker
*
* @return \Acme\sampleBundle\Entity\User
*/
public function getMaker()
{
return $this->maker;
}
}
He revisado todo mil veces y no comprendo porque falla.