Symfony admin generator : filter contents of combobox
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.
精彩评论