To display our list of categories in the DropDown, we need to set the items
property of our DropDown to the self.categories
list we just defined. Go back to your ‘ArticleEdit’ Form and add this line to the __init__
method:
# Any code you write here will run when the form opens.
self.category_box.items = self.categories
The ‘ArticleEdit’ Form should now look like this:
from anvil import *
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
class ArticleEdit(ArticleEditTemplate):
def __init__(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
# Any code you write here will run when the form opens.
self.categories = [(cat['name'], cat) for cat in app_tables.categories.search()]
self.category_box.items = self.categories