Symfony2 FOSUserBundle将resetPasswordform与自定义表单合并

时间:2015-03-30 14:25:32

标签: php forms symfony fosuserbundle

我正在尝试通过合并两种表单类型来创建表单。

与用户实体具有一对一关系的教师实体。

我正在使用FOSUserBundle,我想将ResettingFormType与我的自定义TeacherFormType合并,最终得到一个表单,该表单来自我的自定义& fos重设密码表格。

1-教师实体:

/**
 * @var \User
 * 
 * @ORM\OneToOne(targetEntity="ITJari\UserBundle\Entity\User", fetch="EAGER")
 * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
 * 
 */
private $user;

public function getUser() {
    return $this->user;
}


public function setUser($user) {
    $this->user = $user;
    return $this;
}

2-扩展FOS重置密码:

namespace ITJari\SchoolBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

class ResettingFormType extends AbstractType {

    public function buildForm(FormBuilderInterface $builder, array $options) {

    }

    public function getParent() {
        return 'fos_user_resetting';
    }

    public function getName() {
        return 'ragab';
    }

}

3-教师表格类型

namespace ITJari\SchoolBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class TeacherFormType extends AbstractType {

    public function buildForm(FormBuilderInterface $builder, array $options) {
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver) {
        $resolver->setDefaults(array(
            'data_class' => 'ITJari\SchoolBundle\Entity\Teacher',
        ));
    }

    public function getParent() {
        return 'fos_user_resetting';
    }

    public function getName() {
        return 'teacherform';
    }

}

4-内部控制器:

$teacher = new \ITJari\SchoolBundle\Entity\Teacher();
$teacher->setUser($user);
$form = $this->createForm('teacherform', $teacher); 

但是我收到了以下错误:

  

属性" plainPassword"也不是其中一种方法" getPlainPassword()"," isPlainPassword()"," hasPlainPassword()"," __ get()&# 34;在课堂上存在并具有公共访问权限#IT; ITJari \ SchoolBundle \ Entity \ Teacher"。   500内部服务器错误 - NoSuchPropertyException

0 个答案:

没有答案