From 03987a6e6c51c3aa63fa35bf2643a5f431bf5b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 18 Nov 2019 20:34:08 +0100 Subject: [PATCH] forms: mark invalid prefill value explicitely (#36515) --- wcs/forms/root.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wcs/forms/root.py b/wcs/forms/root.py index 0d34bb547..63d342146 100644 --- a/wcs/forms/root.py +++ b/wcs/forms/root.py @@ -383,6 +383,12 @@ class FormPage(Directory, FormTemplateMixin): if not isinstance(v, str) and field.convert_value_to_str: v = field.convert_value_to_str(v) form.get_widget('f%s' % k).set_value(v) + if field.type == 'item' and form.get_widget('f%s' % k).value != v: + # mark field as invalid if the value was not accepted + # (this is required by quixote>=3 as the value would + # not be evaluated in the initial GET request of the + # page). + form.get_widget('f%s' % k).set_error(get_selection_error_text()) if verified: form.get_widget('f%s' % k).readonly = 'readonly' form.get_widget('f%s' % k).attrs['readonly'] = 'readonly'