「注文」と「住所」という2つのエンティティフォームがあります。住所フォームを注文フォームに埋め込みたい。両方のエンティティは、ユーザー列ごとに関係があります。
アドレスエンティティ
class Address
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=128)
*/
protected $type;
/**
* @ORM\ManyToOne(targetEntity="Root\UserBundle\Entity\User", inversedBy="address")
* @ORM\JoinColumn(name="user", referencedColumnName="id")
* @ORM\ManyToOne(targetEntity="Orders", inversedBy="address")
* @ORM\JoinColumn(name="user", referencedColumnName="user")
*/
protected $user;
注文エンティティ
class Orders
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=128)
*/
protected $status;
/**
* @ORM\ManyToOne(targetEntity="Root\UserBundle\Entity\User", inversedBy="orders")
* @ORM\JoinColumn(name="user", referencedColumnName="id")
* @ORM\OneToMany(targetEntity="Address", mappedBy="orders")
* @ORM\JoinColumn(name="user", referencedColumnName="user")
*/
protected $user;
注文フォーム
namespace Root\ContestBundle\Form\Front;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Root\ContestBundle\Entity\Address;
use Root\ContestBundle\Form\Front\AddressType;
class OrdersType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('address', 'collection', array('type' => new AddressType()));
$builder
->add('termsAccepted');
}
しかし、私は以下のようなエラーが発生しています
An exception has been thrown during the rendering of a template ("Neither property "address" nor method "getAddress()" nor method "isAddress()" exists in class "Root\ContestBundle\Entity\Orders"")
それで、私が自分のコードでどのような間違いを犯したのか。手伝ってください