fix required in form

This commit is contained in:
Cayo Puigdefabregas 2023-04-19 16:17:29 +02:00
parent 6dce475256
commit 1a7c2f3a01
1 changed files with 6 additions and 2 deletions

View File

@ -1293,7 +1293,9 @@ class TradeDocumentForm(FlaskForm):
).one()
kwargs['obj'] = self._obj
if self._obj:
if not self.file_name.args:
self.file_name.args = ("File", [validators.DataRequired()])
if doc_id:
self.file_name.args = ()
super().__init__(*args, **kwargs)
@ -1399,7 +1401,9 @@ class DeviceDocumentForm(FlaskForm):
).one()
kwargs['obj'] = self._obj
if self._obj:
if not self.file_name.args:
self.file_name.args = ("File", [validators.DataRequired()])
if doc_id:
self.file_name.args = ()
super().__init__(*args, **kwargs)