Skip to content

Commit

Permalink
simple FormCollection to test against new FormDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed Jan 16, 2024
1 parent f0099e7 commit 797246c
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions testapp/forms/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
from formset.collection import FormCollection
from formset.dialog import DialogForm
from formset.fields import Button
from formset.widgets import UploadedFileInput
from formset.renderers import ButtonVariant
from formset.widgets import ButtonWidget, UploadedFileInput


class CustomerForm(forms.Form):
class UserNameForm(forms.Form):
username = fields.CharField()
edit_profile = Button(
label="Edit my Profile",
help_text = "Open the dialog to edit the profile",
help_text="Open the dialog to edit the profile",
)


class ProfileForm(DialogForm):
title = "Edit Profile"
open_condition = 'customer.username == "admin" || customer.edit_profile:active'
induce_open = 'customer.username == "admin" || extra_profile:active || customer.edit_profile:active'
induce_close = 'profile.dismiss:active || profile.submit:active'

full_name = fields.CharField(
label="First Name",
Expand All @@ -30,12 +32,28 @@ class ProfileForm(DialogForm):
required=False,
widget=UploadedFileInput,
)
dismiss = Button(
label="Close",
widget=ButtonWidget(
action='activate("close")',
),
)
submit = Button(
label="Save",
widget=ButtonWidget(
action='activate("save")',
button_variant=ButtonVariant.PRIMARY,
),
)


class ProfileCollection(FormCollection):
legend = "Collection with Dialog Form"
customer = CustomerForm()
customer = UserNameForm()

extra_profile = Button()
extra_profile = Button(
label="Extra Profile Button",
help_text="Open the dialog to edit the profile",
)

profile = ProfileForm()

0 comments on commit 797246c

Please sign in to comment.