fields: don't use 'none' string to mark fields with no validation (#35400)
This commit is contained in:
parent
0242d76045
commit
82d6f6a4c9
|
@ -1321,6 +1321,11 @@ def test_form_edit_string_field_validation(pub):
|
|||
resp = resp.form.submit('submit').follow()
|
||||
assert FormDef.get(formdef.id).fields[0].validation == {'type': 'regex', 'value': r'\d+'}
|
||||
|
||||
resp = resp.click('Edit', href='1/')
|
||||
resp.form['validation$type'] = 'None'
|
||||
resp = resp.form.submit('submit').follow()
|
||||
assert FormDef.get(formdef.id).fields[0].validation is None
|
||||
|
||||
resp = resp.click('Edit', href='1/')
|
||||
resp.form['validation$type'] = 'Django Condition'
|
||||
resp.form['validation$value_django'] = 'value|decimal < 20'
|
||||
|
|
|
@ -917,7 +917,7 @@ class ValidationWidget(CompositeWidget):
|
|||
if not value:
|
||||
value = {}
|
||||
|
||||
options = [('none', _('None'))] + [(x, _(y['title'])) for x, y in self.validation_methods.items()]
|
||||
options = [(None, _('None'))] + [(x, _(y['title'])) for x, y in self.validation_methods.items()]
|
||||
|
||||
self.add(SingleSelectWidget, 'type', options=options, value=value.get('type'),
|
||||
attrs={'data-dynamic-display-parent': 'true'})
|
||||
|
@ -968,7 +968,7 @@ class ValidationWidget(CompositeWidget):
|
|||
return condition.evaluate()
|
||||
return django_validation
|
||||
validation_method = cls.validation_methods.get(validation['type'])
|
||||
if 'function' in validation_method:
|
||||
if validation_method and 'function' in validation_method:
|
||||
return getattr(misc, validation_method['function'])
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Reference in New Issue