我有两个实体表格,分别称为“订单”和“地址”。我想将地址表格嵌入到订单表格中。两个实体都与用户列有关系。
地址实体
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"")
那么我在代码中犯了什么错误。帮帮我