stages/prompt: force required to false when using readonlyfield

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-07-08 22:38:37 +02:00
parent 4c14c7f3a4
commit ff500b44a6
1 changed files with 2 additions and 0 deletions

View File

@ -148,6 +148,8 @@ class Prompt(SerializerModel):
kwargs["allow_blank"] = not self.required kwargs["allow_blank"] = not self.required
if self.type == FieldTypes.TEXT_READ_ONLY: if self.type == FieldTypes.TEXT_READ_ONLY:
field_class = ReadOnlyField field_class = ReadOnlyField
# required can't be set for ReadOnlyField
kwargs["required"] = False
if self.type == FieldTypes.EMAIL: if self.type == FieldTypes.EMAIL:
field_class = EmailField field_class = EmailField
kwargs["allow_blank"] = not self.required kwargs["allow_blank"] = not self.required