Objective
具有一個Perspective
Symfony2中 - 在字段形式的問題與映射對象
class Objective{
...
public function setPerspective(\Cboujon\BSCBundle\Entity\Pespective $perspective = null)
{
$this->perspective = $perspective;
return $this;
}
}
Objective.orm.yml
Cboujon\BSCBundle\Entity\Objective:
manyToOne:
perspective:
targetEntity: Perspective
inversedBy: objectives
joinColumn:
name: perspective_id
referencesColumn: id
ObjectiveType.php
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('perspective');
}
Symfony2呈現與所有觀點的組合框的窗體。那沒問題! butn當我提交create form
我得到的錯誤:
ContextErrorException: Catchable Fatal Error: Argument 1 passed to Cboujon\BSCBundle\Entity\Objective::setPerspective() must be an instance of Cboujon\BSCBundle\Entity\Pespective, instance of Cboujon\BSCBundle\Entity\Perspective given, called in /home/cristhian/php_apps/Symfony/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php on line 376 and defined in /home/cristhian/php_apps/Symfony/src/Cboujon/BSCBundle/Entity/Objective.php line 63
注:我也嘗試:
$builder->add('perspective', 'entity', array(
'class' => 'CboujonBSCBundle:Perspective',
)
)
;
,但我得到了同樣的錯誤。注2:如果我從setPerspective定義中刪除\Cboujon\BSCBundle\Entity\Pespective
,我可以提交表單OK。
我在做什麼錯?