User tests: Successful: Unsuccessful:
As far as I see, #12414 seems to have broken the form validation for some fields (except those components which do their own validation after the form validation, like com_users). Please check and inform me if I'm mistaken.
The method FormField::validate
checks whether the return value of FormRule::test
is false and handles errors only in this particular case, returning a simple true
for all other cases. The problem here is that FormRule::test
might also return an Exception on failure, which doesn't evaluate to false
.
A quick glance through the different validation rules shows that this is the case for EmailRule
and under some circumstances maybe also for NotequalsRule
.
I suppose that this bug can be solved by not naively returning true, but the very result of the validation instead. Of course, another method would be to unify the way we want to treat validation errors by deciding on either returning booleans, returning exceptions or throwing exceptions.
The form should not be saved and return an error.
The form is saved.
Please also test that valid form submissions are still valid!
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
okay, I see,
old had:
$valid = $rule->test($element, $value, $group, $input, $this);
// Check for an error in the validation test.
if ($valid instanceof \Exception)
{
return $valid;
}
and new:
try
{
// Run the field validation rule test.
$valid = $rule->test($this->element, $value, $group, $input, $this->form);
}
catch (\Exception $e)
{
return $e;
}
so now it ignores if $valid
are Exception
.
The patch are good.
Labels |
Added:
?
|
I have tested this item
works as descriped
I have tested this item
works as advertised
Status | Pending | ⇒ | Ready to Commit |
RTC
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-11-03 00:44:20 |
Closed_By | ⇒ | wilsonge | |
Labels |
Added:
?
|
Thanks!
hm, maybe something else are broken?
because old behavior also has
return true;
https://github.com/joomla/joomla-cms/blob/staging/libraries/src/Form/Form.php#L2148or it was always broken