We want our alert to display the ‘ArticleEdit’ Form. To do this, we first need to import the ArticleEdit Form inside our Homepage Form.
Add this line to the top of your ‘Homepage’ Form:
from ..ArticleEdit import ArticleEdit
We can now display the ‘ArticleEdit’ Form in our popup by customising the alert using Anvil’s custom popup styles. Set the content
property of the alert to an instance of the ‘ArticleEdit’ Form, set the title
property to “Add an article”, and set the large
property to True
:
def add_article_button_click(self, **event_args):
# Open an alert displaying the 'ArticleEdit' Form
alert(
content=ArticleEdit(),
title="Add Article",
large=True,
)
When you run your app and click the button, you should get the ArticleEdit form in a popup box: