File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,13 @@ def validate_comma_separated_emails(value):
51
51
for v in value .split ("," ):
52
52
validate_email (v .strip ())
53
53
54
+ def email_field_choices (form : forms .ModelForm | None , required : bool = True ) -> list [tuple [str , str ]]:
55
+ if not form :
56
+ return []
57
+ email_fields = form .instance .fields .filter (type = 'email' )
58
+ choices = [] if required else [('' , '--' )]
59
+ choices .extend ([(_ .name , _ .title ) for _ in email_fields ])
60
+ return choices
54
61
55
62
class Form (models .Model ):
56
63
CONFIG_OPTIONS = [
@@ -86,13 +93,13 @@ class Form(models.Model):
86
93
),
87
94
(
88
95
"author_email_field" ,
89
- forms .CharField (
96
+ forms .ChoiceField (
90
97
label = capfirst (_ ("author's email field" )),
91
98
help_text = _ (
92
99
"The author of the submission will be added to the Cc: if this is set to an existing form field below."
93
100
),
94
101
required = False ,
95
- widget = widgets . AdminTextInputWidget ,
102
+ choices = email_field_choices ( form , required = False ) ,
96
103
),
97
104
),
98
105
],
You can’t perform that action at this time.
0 commit comments