-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Access container array in Expression/Context #12315
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
Comments
Also, when using Callback constraint. The new Callback(function($value, ExecutionContext $context) {
/** @var Form $form */
$form = $context->getRoot();
$validatedArray = $form->getData();
}); |
Thank you for creating this issue @slavafomin! I'm tagging this as a feature request. |
After 3 years seems like this feature still not implemented.. sad. |
@Arkemlar ... which means nobody stepped up to implement it. Would you like to give it a go? |
@fabpot I would try to implement it, it seems not so complicated. |
* add dataPath Property to extract "this" in a different way from the context
* update changelog
Related to #22403 ;) |
* add dataPath Property to extract "this" in a different way from the context
* update changelog
* change string check
* change test method name to a better name
* add dataPath Property to extract "this" in a different way from the context
* update changelog
* change string check
* change test method name to a better name
* moved check if property access component is installed to constraint * improve readability
* made dataPath private
* made dataPath protected so test is not failing
… constraint (ostrolucky) This PR was merged into the 2.7 branch. Discussion ---------- [Validator] Fix access to root object when using composite constraint | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #12315, #20477, #21706 | License | MIT | Doc PR | Commits ------- b18cdcf [Validator] Fix access to root object when using composite constraint
Hi!
We can use Expression constraint on the object's property and object itself will be accessible from inside the expression via
this
keyword. However, when validating plain arrays instead of objects, we can't access array itself, in this casethis
has anull
value. I think we should also allow entire array to be accessed from inside the expression.Here's example of how it can be used with form builder:
https://gist.github.com/slavafomin/805d36fe671fbdc3aced
The text was updated successfully, but these errors were encountered: