如何在没有fosUser的情况下在fosCommentBundle中添加输入用户名?
How to add the input username in fosCommentBundle without fosUser?
我想在不使用 FOSUserBundlde 的情况下在捆绑包 FOSCommentBundle 中添加用户名字段(输入)。
用户必须输入他的用户名和评论。
基本模型不提供伪字段,因为它依赖于连接的用户或 "anonymous" 如果没有连接的用户。
你能告诉我怎么做吗?
Symfony 4.4
谢谢
捆绑包中的评论只是配置中贴标的实体。我想你做到了?
创建您自己的评论实体
https://github.com/FriendsOfSymfony/FOSCommentBundle/blob/master/Resources/doc/2a-mapping_orm.md
所以我认为您只需将新的 属性 $userName
添加到您的评论实体即可。我找到了这个 https://github.com/FriendsOfSymfony/FOSCommentBundle/issues/334
覆盖捆绑包部分
我从未使用过那个包,但问题评论中回答的是纯粹的 symfony 行为。您必须覆盖 Bundle 的表单和模板。
那个表格:
https://github.com/FriendsOfSymfony/FOSCommentBundle/blob/master/Form/CommentType.php
覆盖任何包中的 FormType
https://symfony.com/doc/4.4/form/create_form_type_extension.html
并覆盖模板
https://symfony.com/doc/current/bundles/override.html#templates
我想在不使用 FOSUserBundlde 的情况下在捆绑包 FOSCommentBundle 中添加用户名字段(输入)。
用户必须输入他的用户名和评论。 基本模型不提供伪字段,因为它依赖于连接的用户或 "anonymous" 如果没有连接的用户。
你能告诉我怎么做吗?
Symfony 4.4
谢谢
捆绑包中的评论只是配置中贴标的实体。我想你做到了?
创建您自己的评论实体
https://github.com/FriendsOfSymfony/FOSCommentBundle/blob/master/Resources/doc/2a-mapping_orm.md
所以我认为您只需将新的 属性 $userName
添加到您的评论实体即可。我找到了这个 https://github.com/FriendsOfSymfony/FOSCommentBundle/issues/334
覆盖捆绑包部分
我从未使用过那个包,但问题评论中回答的是纯粹的 symfony 行为。您必须覆盖 Bundle 的表单和模板。
那个表格: https://github.com/FriendsOfSymfony/FOSCommentBundle/blob/master/Form/CommentType.php
覆盖任何包中的 FormType
https://symfony.com/doc/4.4/form/create_form_type_extension.html
并覆盖模板
https://symfony.com/doc/current/bundles/override.html#templates