如何配置多对多关系以在文本字段中显示(如标签)

发布于 2025-01-07 05:28:58 字数 331 浏览 2 评论 0原文

我有一个带有电影评论表格的电影评论网站,其中电影与演员有多对多的关系。

现在我想提供一个文本字段(将来具有自动完成功能),我可以在其中将演员添加到电影中。

我有这个代码: $builder->add('actors','textarea');,但它提供了一个文本字段,其中包含以下奇怪的预填充文本内容:

Doctrine\Common\Collections\ArrayCollection@0000000051c7ab6e00000000d586d059

我如何将其表示为文本我可以在其中添加演员(如标签)的字段?

I have a website for movie reviews with movie review form, where movies have many-to-many relationship to actors.

Now I want to offer a text field (in future with autocomplete), where I can add actors to the movie.

I have this code: $builder->add('actors','textarea');, but it offers a text field with following weird prefilled text content:

Doctrine\Common\Collections\ArrayCollection@0000000051c7ab6e00000000d586d059

How can I represent this as a text field where I can add actors (like tags)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿挽旧人 2025-01-14 05:28:58

查看此食谱条目。这应该为您指明此类功能的正确方向。

您在文本区域中获取该内容是因为 symfony2 表单元素使用电影实体上的 getActors() 方法预先填充该内容。

Check out this cookbook entry. That should point you in the right direction for this kind of functionality.

You are getting that content in the text area because the symfony2 form element is pre-filling it with the getActors() method on your movie entity.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文