Skip to content

Commit ed21076

Browse files
1682 Adds second page to test form
1 parent f86b887 commit ed21076

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

backend/main.py

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ class Person(BaseModel):
126126
@app.post("/form")
127127
async def form(form_data: list[dict] = []):
128128
def form_generator(state: State):
129-
class TestForm(FormPage):
130-
model_config = ConfigDict(title="Form Title")
129+
class TestForm1(FormPage):
130+
model_config = ConfigDict(title="Form Title Page 1")
131131

132132
number: NumberExample = 3
133133
text: Annotated[str, Field(min_length=3, max_length=12)] = "Default text"
@@ -147,16 +147,40 @@ class TestForm(FormPage):
147147

148148
person: Person
149149

150-
form_data_1 = yield TestForm
150+
form_data_1 = yield TestForm1
151151

152-
class TestForm2(SubmitFormPage):
153-
model_config = ConfigDict(title="Form 2 Title")
152+
# todo rename to avoid duplicate field names
153+
class TestForm2(FormPage):
154+
model_config = ConfigDict(title="Form Title Page 2")
154155

155-
name_2: str | None = None
156+
number: NumberExample = 3
157+
text: Annotated[str, Field(min_length=3, max_length=12)] = "Default text"
158+
textArea: LongText = "Text area default"
159+
divider: Divider
160+
label: Label = "Label"
161+
hidden: Hidden = "Hidden"
162+
# When there are > 3 choices a dropdown will be rendered
163+
dropdown: DropdownChoices = "2"
164+
# When there are <= 3 choices a radio group will be rendered
165+
radio: RadioChoices = "3"
166+
# checkbox: bool = True TODO: Fix validation errors on this
167+
168+
# When there are <= 5 choices in a list a set of checkboxes are rendered
169+
# multicheckbox: choice_list(MultiCheckBoxChoices, min_items=3) = ["1", "2"]
170+
# list: choice_list(ListChoices) = [0, 1]
171+
172+
person: Person
156173

157174
form_data_2 = yield TestForm2
158175

159-
return form_data_1.model_dump() | form_data_2.model_dump()
176+
class TestSubmitForm(SubmitFormPage):
177+
model_config = ConfigDict(title="Submit Form")
178+
179+
name_2: str | None = None
180+
181+
form_data_submit = yield TestSubmitForm
182+
183+
return form_data_1.model_dump() | form_data_2.model_dump() | form_data_submit.model_dump()
160184

161185
post_form(form_generator, state={}, user_inputs=form_data)
162186
return "OK!"

0 commit comments

Comments
 (0)