Symfony FOSUser 覆盖 resettingForm

Symfony FOSUser override resettingForm

我无法完成 resettingFrom 覆盖。而我是为注册表格做的。这是我的相关文件:

services.yml:

    mycars_frontend.resetting.form.type:
        class: Mycars\Website\FrontendBundle\Form\Type\ResettingFormType
        arguments: [%fos_user.model.user.class%]
        tags:
            - { name: form.type, alias: mycars_frontend_resetting }

resettingFormType.php :

namespace Mycars\Website\FrontendBundle\Form\Type;

use Symfony\Component\Form\FormBuilderInterface;
use FOS\UserBundle\Form\Type\ResettingFormType as AbstractType;

class ResettingFormType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);

        $builder->add('City');
    }
    public function getName()
    {
        return 'mycars_frontend_resetting';
    }
}

config.yml:

fos_user:
    db_driver: orm
    firewall_name: main
    user_class: Mycars\Website\FrontendBundle\Entity\Customer
    registration:
        form:
            type: mycars_frontend_registration
    resetting:
        form:
            type: mycars_frontend_resetting

Customer.php

namespace Mycars\Website\FrontendBundle\Entity;

use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * Mycars\Website\FrontendBundle\Entity\Customer
 *
 * @ORM\Entity(repositoryClass="CustomerRepository")
 * @ORM\Table(name="Customer")
 */

class Customer extends BaseUser
{

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */

    protected $id;

    /**
     * @ORM\Column(type="string", length=32, nullable=true)
     */
    protected $Civilite;

    /**
     * @ORM\Column(type="string", length=32, nullable=true)
     */
    protected $Firstname;

    /**
     * @ORM\Column(type="string", length=32, nullable=true)
     */
    protected $Lastname;

    /**
     * @ORM\Column(type="string", length=32, nullable=true)
     */
    protected $Phone;

    /**
     * @ORM\Column(type="text", nullable=true)
     */
    protected $Address1;

    /**
     * @ORM\Column(type="text", nullable=true)
     */
    protected $Address2;

    /**
     * @ORM\Column(type="string", length=5, nullable=true)
     */
    protected $Zipcode;

    /**
     * @ORM\Column(type="string", length=64, nullable=true)
     */
    protected $City;

我没有错误,只是正常的配置文件编辑表单.. 谢谢!

我认为您可能需要重写 ResettingController 并指定要使用的表单。

在您的服务定义中有一个拼写错误:

mycars_frontend.resetting.form.type:

但应该是:

mycars_frontend_resetting.form.type:

我用 "frontend" 和 "resetting" 之间的点 (.) 替换为下划线 (_)。