【问题标题】:fosuserbundle custom form config in symfony 2.8symfony 2.8 中的 fosuserbundle 自定义表单配置
【发布时间】:2016-04-16 00:13:15
【问题描述】:

当我配置 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。

【问题讨论】:

    标签: forms alias symfony-2.8


    【解决方案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 分支。

    【讨论】:

    • 为了让您的答案对其他用户更有用,您可以提供一个完全限定类名的示例并提供详细信息的链接。
    猜你喜欢
    • 1970-01-01
    • 2016-05-14
    • 1970-01-01
    • 1970-01-01
    • 2017-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-30
    相关资源
    最近更新 更多