Cri*_*jon 0 php forms symfony doctrine-orm
Objective
有一个 Perspective
class Objective{
...
public function setPerspective(\Cboujon\BSCBundle\Entity\Pespective $perspective = null)
{
$this->perspective = $perspective;
return $this;
}
}
Run Code Online (Sandbox Code Playgroud)
Objective.orm.yml
Cboujon\BSCBundle\Entity\Objective:
manyToOne:
perspective:
targetEntity: Perspective
inversedBy: objectives
joinColumn:
name: perspective_id
referencesColumn: id
Run Code Online (Sandbox Code Playgroud)
ObjectiveType.php
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('perspective');
}
Run Code Online (Sandbox Code Playgroud)
Symfony2使用具有所有视角的组合框呈现一个表单.那没问题!但当我提交时,create form
我收到错误:
ContextErrorException:Catchable Fatal Error:传递给Cboujon\BSCBundle\Entity \的参数1:Objective :: setPerspective()必须是Cboujon\BSCBundle\Entity\Pespective的实例,Cboujon\BSCBundle\Entity\Perspective的实例,在/ home中调用第376行的/cristhian/php_apps/Symfony/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php,在/home/cristhian/php_apps/Symfony/src/Cboujon/BSCBundle/Entity/Objective.php中定义第63行
注意:我也尝试:
$builder->add('perspective', 'entity', array(
'class' => 'CboujonBSCBundle:Perspective',
)
)
;
Run Code Online (Sandbox Code Playgroud)
但我得到了同样的错误.
注意2:如果我\Cboujon\BSCBundle\Entity\Pespective
从setPerspective定义中删除,我可以提交表单确定.
我究竟做错了什么?
在指定参数类型时,iThere是您的实体设置器中的拼写错误:
public function setPerspective(\Cboujon\BSCBundle\Entity\Pespective $perspective = null)
{
$this->perspective = $perspective;
return $this;
}
Run Code Online (Sandbox Code Playgroud)
不是\ Cboujon\BSCBundle \实体\ 阈看,但\ Cboujon\BSCBundle \实体\ 视角
归档时间: |
|
查看次数: |
230 次 |
最近记录: |