-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.py
More file actions
24 lines (16 loc) · 808 Bytes
/
model.py
File metadata and controls
24 lines (16 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Model implementation for conditional rendering example."""
from pydantic import BaseModel, Field
class FormData(BaseModel):
"""Pydantic model for the form data."""
comments: str = Field(default="", title="Comments")
email_address: str = Field(default="", title="Email Address")
full_name: str = Field(default="", title="Full Name")
phone_number: str = Field(default="", title="Phone Number")
show_phone_field: bool = Field(default=False, title="Add Phone Number?")
show_comments_field: bool = Field(default=False)
class Model:
"""Model implementation for conditional rendering example."""
def __init__(self) -> None:
self.form = FormData()
def toggle_comments(self) -> None:
self.form.show_comments_field = not self.form.show_comments_field