🐞 Fixed disappearing numeric field element keys#6
Merged
yoan-myparcel merged 2 commits intomasterfrom Sep 26, 2025
Merged
Conversation
src/Form/Form.php
Outdated
| $validator->getErrors(), | ||
| ); | ||
| throw new FormValidationException("Form validation failed", $validator->getErrors()); | ||
| throw new FormValidationException("Form validation failed", $errorMessages); |
There was a problem hiding this comment.
FormValidationException::render expects $this->errors to have a property and a message key, so passing $errorMessages here will cause an undefined index error. I think $errorMessages can be deleted
yoerriwalstra
approved these changes
Sep 26, 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 pull request refactors how form element values are collected and returned, ensuring that keys are consistently integers and simplifying the value extraction logic. It also updates error handling in validation and aligns related tests to the new data structure.
Form value extraction improvements:
getValuesinFormElementCollectionto useArr::mapWithKeys, which directly maps element names to their values, simplifying the code and ensuring keys are not collapsed or transformed unexpectedly. (src/Form/FormElementCollection.php, src/Form/FormElementCollection.phpL49-L56)Validation error handling:
validatemethod inFormto throwFormValidationExceptionwith formatted error messages rather than raw error arrays, making errors clearer and easier to consume. (src/Form/Form.php, src/Form/Form.phpL45-R45)Test updates for new value structure:
FormTestto use integer keys for form element names, reflecting the changes to the value extraction logic. (tests/Form/FormTest.php, [1] [2]