mirror of
https://codeberg.org/angestoepselt/homepage.git
synced 2025-05-24 14:46:16 +00:00
Apply default value for string form fields if they are empty
This commit is contained in:
parent
740c2fff3f
commit
a0f9dd8b8f
1 changed files with 2 additions and 0 deletions
|
|
@ -172,6 +172,8 @@ def get_form_value(
|
|||
result = cast(form.getfirst(name))
|
||||
if isinstance(result, str):
|
||||
result = result.strip()
|
||||
if not result and default is not None:
|
||||
return default
|
||||
return result
|
||||
except (TypeError, ValueError):
|
||||
fail("400 Bad Request", f"Invalid value for field: {name}")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue