-1

当我配置 FOS USer Bundle 时,我可以在配置中使用别名设置自定义表单,例如:

<service id="my.security.type.change.password" class="%my.security.type.change.password.class%">
        <argument>%fos_user.model.user.class%</argument>
        <tag name="form.type" alias="my_change_password" />
    </service>

 ...

 fos_user:
    change_password:
        form:
             type: my_change_password

bun 别名表单配置在 symfony 2.8 中已弃用,所以我想知道如何在 symfony 2.8 yaml 配置中通过名称来引用 fomr。

4

1 回答 1

-1

使用完全限定的类名,例如:

<parameter key="my.security.type.change.password.class">FOS\UserBundle\Form\Type\ChangePasswordFormType</parameter>

<service id="my.security.type.change.password" class="%my.security.type.change.password.class%">
    <argument>%fos_user.model.user.class%</argument>
    <tag name="form.type" />
</service>

...

 fos_user:
    change_password:
        form:
             type: FOS\UserBundle\Form\Type\ChangePasswordFormType

来源:https ://symfony.com/doc/master/bundles/FOSUserBundle/configuration_reference.html用于 FOS User Bundle 2.0 分支。

于 2016-01-11T16:02:42.590 回答