开发者

Symfony admin generator : filter contents of combobox

开发者 https://www.devze.com 2023-02-07 21:50 出处:网络
I\'m building a blog engine to learn symfony. I have an admin page where logged in authors can add \"author comments\" under any published content, using a combobox to choose the content title.

I'm building a blog engine to learn symfony.

I have an admin page where logged in authors can add "author comments" under any published content, using a combobox to choose the content title.

How can I filter the items in the combobox, to only show Contents written by that author ?开发者_如何学Python Should I create a new widget, how ?

Edit : should I use a textbox with some sort of autocomplete ?


I'm assuming you use doctrine. If you check the source of sfWidgetFormDoctrineChoice you'll see it accepts a query parameter that it will use to fetch the items displayed.

Create a Doctrine_Query object in your form's configure method, filter it for the current user's articles, and pass it via this option to the widget. And make sure you do the same with the validator.

0

精彩评论

暂无评论...
验证码 换一张
取 消