Closed Joubinho closed 1 year ago
7.4, 8.0, 8.1, 8.2
4.3.1
Composer (using codeigniter4/appstarter)
codeigniter4/appstarter
macOS, Windows
apache
No response
When using many SetRule from Validation service in order :
$validation->setRule('username', 'Username', 'required');
Then
$validation->setRule('password', 'Password', 'required');
Errors are shown in reverse order. ("Password error" then "Username error")
When using many SetRule from Validation service like that :
$validation = \Config\Services::validation(); $validation->setRule('username', 'Username', 'required'); $validation->setRule('password', 'Password', 'required'); if ($this->validation->withRequest($this->request)->run()) {...}
Submit your form and show errors in view with : <?= validation_list_errors() ?>
<?= validation_list_errors() ?>
"Username error" then "Password error"
The problem seems to be in Validation/Validation.php line 446 When I replace :
$this->setRules($ruleSet + $this->getRules(), $this->customErrors);
By :
$this->setRules($this->getRules() + $ruleSet, $this->customErrors);
It's in the right order (but may cause other problem).
I send PR #7149
PHP Version
7.4, 8.0, 8.1, 8.2
CodeIgniter4 Version
4.3.1
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter
)Which operating systems have you tested for this bug?
macOS, Windows
Which server did you use?
apache
Database
No response
What happened?
When using many SetRule from Validation service in order :
Then
Errors are shown in reverse order. ("Password error" then "Username error")
Steps to Reproduce
When using many SetRule from Validation service like that :
Submit your form and show errors in view with :
<?= validation_list_errors() ?>
Expected Output
"Username error" then "Password error"
Anything else?
The problem seems to be in Validation/Validation.php line 446 When I replace :
By :
It's in the right order (but may cause other problem).