We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
name: Bug report about: Bug (misleading code) in example for "Validating $_POST data"
Describe the bug
The following code is mentioned in "Validating $_POST data":
`public function updateUser(int $userID) { if (! $this->validate([ 'email' => "required|is_unique[users.email,id,{$userID}]", 'name' => 'required|alpha_numeric_spaces' ])) { return view('users/update', [ 'errors' => $this->errors ]); }
// do something here if successful...
}`
This code gives the impression that the controller class has a variable called "$errors" but this is not the case.
A solution is to use \Config\Services::validation()->getErrors() instead of $this->errors.
\Config\Services::validation()->getErrors()
$this->errors
PS: The same applies for the second example code in the same section!
CodeIgniter 4 version CodeIgniter 4 Alpha 2
The text was updated successfully, but these errors were encountered:
please try latest develop branch, I can see that it already uses $this->validator->getErrors() at https://github.com/codeigniter4/CodeIgniter4/blob/develop/user_guide_src/source/incoming/controllers.rst#validating-_post-data
develop
$this->validator->getErrors()
Sorry, something went wrong.
Agreed, This has already been addressed.
No branches or pull requests
name: Bug report
about: Bug (misleading code) in example for "Validating $_POST data"
Describe the bug
The following code is mentioned in "Validating $_POST data":
`public function updateUser(int $userID)
{
if (! $this->validate([
'email' => "required|is_unique[users.email,id,{$userID}]",
'name' => 'required|alpha_numeric_spaces'
]))
{
return view('users/update', [
'errors' => $this->errors
]);
}
}`
This code gives the impression that the controller class has a variable called "$errors" but this is not the case.
A solution is to use
\Config\Services::validation()->getErrors()
instead of$this->errors
.PS: The same applies for the second example code in the same section!
CodeIgniter 4 version
CodeIgniter 4 Alpha 2
The text was updated successfully, but these errors were encountered: