Add formClass option to the SearchComponent.#354
Merged
Merged
Conversation
This allows specifying a form class to use for the search form. It primarily helps in validating the search params before performing a redirect.
ADmad
commented
Oct 3, 2025
| * @return array | ||
| */ | ||
| protected function _filterParams(): array | ||
| protected function _filterParams(array $params): array |
Member
Author
There was a problem hiding this comment.
@dereuromark This is a breaking signature change but I think it's acceptable for a protected method in a new minor release.
There was a problem hiding this comment.
Pull Request Overview
This PR adds form validation capabilities to the SearchComponent by introducing a new formClass configuration option. The component can now use a CakePHP Form class to validate search parameters before redirecting, providing better user experience and data validation.
- Added
formClassconfiguration option to SearchComponent for optional form validation - Modified startup flow to validate POST data against the form before redirecting
- Added test coverage for form validation scenarios and documentation
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Controller/Component/SearchComponent.php | Added formClass config, form instantiation logic, and validation flow |
| tests/TestCase/Controller/Component/SearchComponentTest.php | Added test methods for form validation scenarios |
| tests/TestApp/Form/SearchForm.php | Created test form class with validation rules |
| docs/additional-docs.md | Added documentation for the new formClass feature |
| phpcs.xml | Removed redundant installed_paths configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
dereuromark
approved these changes
Oct 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This allows specifying a form class to use for the search form. It primarily helps in validating the search params before performing a redirect.
TODO: Add docs and do some in app testing.