Skip to content
New issue

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

fix: support for display of error message using wildcard (*) #7226

Merged
merged 3 commits into from
Feb 7, 2023

Conversation

sammyskills
Copy link
Contributor

@sammyskills sammyskills commented Feb 5, 2023

Description
The validation_show_error() form helper does not support the use of wildcards (*) like the getError() validation method.

For example, if I have a rule like this:

$rules = [
    'users.*.name' => "required"
];

I expect that I should be able to display the error in the view using validation_show_error('users.*.name') just the same way I would if I use $validation->getError('users.*.name').
This PR fixes that.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Feb 5, 2023
@kenjis kenjis changed the title Add support for display of error message using wildcard (*) fix: support for display of error message using wildcard (*) Feb 5, 2023
Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we just call the showError() from the Validation class? Am I missing something here?

@sammyskills
Copy link
Contributor Author

sammyskills commented Feb 5, 2023

If you use redirect()->back()->withInput() in the controller and validation_show_error() in the view file, error message for rules that contains wildcards (*) will not be displayed.

IMO, I don't think it is a good idea to call the validation object again using $validation->getError() since it is already done in the form helper function.

Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I missed the part where we're checking the session info. This is fine. Thanks!

@kenjis kenjis merged commit 4274fbf into codeigniter4:develop Feb 7, 2023
@sammyskills sammyskills deleted the error-wildcard-support branch February 7, 2023 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants