Skip to content

Commit bf49a72

Browse files
committed
fix: redirect()->withInput() or withErrors() causes ValidationException
#381
1 parent 1f0e8b4 commit bf49a72

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/Models/CheckQueryReturnTrait.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ private function checkQueryReturn($return): void
3232

3333
private function checkValidationError(): void
3434
{
35-
$validationErrors = $this->validation->getErrors();
35+
$validationErrors = $this->getValidationErrors();
3636

3737
if ($validationErrors !== []) {
3838
$message = 'Validation error:';
@@ -45,6 +45,25 @@ private function checkValidationError(): void
4545
}
4646
}
4747

48+
/**
49+
* Gets real validation errors that are not saved in the Session.
50+
*
51+
* @return string[]
52+
*/
53+
private function getValidationErrors(): array
54+
{
55+
return $this->getValidationPropertyErrors();
56+
}
57+
58+
private function getValidationPropertyErrors(): array
59+
{
60+
$refClass = new ReflectionObject($this->validation);
61+
$refProperty = $refClass->getProperty('errors');
62+
$refProperty->setAccessible(true);
63+
64+
return $refProperty->getValue($this->validation);
65+
}
66+
4867
private function disableDBDebug(): void
4968
{
5069
if (! $this->db->DBDebug) {

0 commit comments

Comments
 (0)