エンティティを更新しようとすると、次の例外が発生します。
The form's view data is expected to be of type scalar, array or an instance of \ArrayAccess, but is an instance of class Proxies__CG__\Acme\DemoBundle\Entity\TicketCategory. You can avoid this error by setting the "data_class" option to "Proxies__CG__\Acme\DemoBundle\Entity\TicketCategory" or by adding a view transformer that transforms an instance of class Proxies__CG__\Acme\DemoBundle\Entity\TicketCategory to scalar, array or an instance of \ArrayAccess.
作成時は問題なく関係はOKです。ただし、更新すると、この奇妙な例外が発生します。私のエンティティは次のように設定されています:
class Ticket
{
// ...
/**
* @var TicketCategory
*
* @ORM\ManyToOne(targetEntity="TicketCategory")
* @ORM\JoinColumn(name="category_id", referencedColumnName="id")
*/
protected $category;
// ...
}
class TicketCategory
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string $title
*
* @ORM\Column(name="title", type="string", length=255)
* @Assert\NotBlank()
*/
private $title;
// ...
}
形
class TicketType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('title', 'text', array(
'error_bubbling' => true,
)
)
->add('category', 'text', array(
'error_bubbling' => true,
)
)
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Acme\DemoBundle\Entity\Ticket',
'csrf_protection' => false,
));
}
public function getName()
{
return '';
}
}
アイデアはありますか?