如何配置多对多关系以在文本字段中显示(如标签)
我有一个带有电影评论表格的电影评论网站,其中电影与演员有多对多的关系。
现在我想提供一个文本字段(将来具有自动完成功能),我可以在其中将演员添加到电影中。
我有这个代码: $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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看此食谱条目。这应该为您指明此类功能的正确方向。
您在文本区域中获取该内容是因为 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.