Skip to content

Commit

Permalink
allow Form(..., validation=lambda form: form.vars.update(key=value))
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed Jun 15, 2024
1 parent 1b02e8a commit 678992c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions py4web/utils/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,15 +823,20 @@ def __init__(
validation(self)
if not self.errors:
for file in uploaded_files:
field, value = file
value = field.store(
value.file, value.filename, field.uploadfolder
)
if value is not None:
validated_vars[field.name] = value
if field.name not in self.vars:
field, value = file
value = field.store(
value.file, value.filename, field.uploadfolder
)
if value is not None:
self.vars[field.name] = value
self.accepted = True
self.vars.update(validated_vars)
if dbio:
validated_vars = {
k: v
for k, v in self.vars.items()
if k != "id"
}
self.update_or_insert(validated_vars)
elif dbio:
self.accepted = True
Expand Down

0 comments on commit 678992c

Please sign in to comment.