form field `clean` now force-stringifies value

This commit is contained in:
Daniil Fajnberg 2022-04-26 21:55:56 +02:00
parent 87c1960cd4
commit 6b241feda5
1 changed files with 2 additions and 1 deletions

View File

@ -61,7 +61,8 @@ class FormField:
def valid_option(self, option: str) -> bool:
return self.options is None or option in self.options.keys() or option in self.options.values()
def clean(self, value: str) -> str:
def clean(self, value: Any) -> str:
value = str(value)
if self.options is None or value in self.options.keys():
return value
# Try to find an unambiguous match in the visible option texts: