- Issue created by @arousseau
- Merge request !23Added OptionsProviderInterface implementation #3474619 → (Merged) created by arousseau
- Status changed to Needs review
2 months ago 8:03am 16 September 2024 -
arousseau →
committed fc35820b on 2.0.x
Added OptionsProviderInterface implementation #3474619
-
arousseau →
committed fc35820b on 2.0.x
- Status changed to Fixed
2 months ago 8:09am 16 September 2024 - 🇫🇷France arousseau
Well this actually looks a bit more complex than anticipated.
If we implement
OptionsProviderInterface
Drupal adds a\Symfony\Component\Validator\Constraints\Choice
to the field.
Which in turns, when validating the entity, calls\Drupal\jsonapi_reference\Plugin\Field\FieldType\TypedResourceObjectItem::getSettableValues
Problem :
getSettableValues
will only return the first 50 elements that JSON:API provides. There is then a good chance that those results, which aren't filtered using the search attribute used by the field widget, don't contain the value set for the field.This makes validation fail :/
I'm not sure what would be the best way to handle this, since using pagination to fetch all possible values for the field would be a big hit on performance I would imagine.
- Status changed to Needs work
2 months ago 10:09am 16 September 2024 - 🇬🇧United Kingdom Eli-T Manchester
Agrre that validation via pagination is prohibitive.
Let's back this out for now so we can release an alpha supporting Drupal 11.
- 🇬🇧United Kingdom Eli-T Manchester
I have reverted the change directly on the 2.0.x branch.
- 🇫🇷France arousseau
Hi eli-t!
Do you think it would be acceptable to remove the\Drupal\jsonapi_reference\Plugin\Field\FieldType\TypedResourceObjectItem::getConstraints
call?
As it is, it only returns theAllowedValues
constraint, which we do not want/can't provide for performance reasons.We could have something like this instead https://git.drupalcode.org/issue/jsonapi_reference-3474619/-/commit/057c...
- 🇬🇧United Kingdom Eli-T Manchester
I think this is probably a good idea. Let's give it a try.
- Merge request !25#3474619: restore OptionsProviderInterface to TypedResourceObjectItem but... → (Merged) created by Eli-T
- 🇬🇧United Kingdom Eli-T Manchester
This MR does that
https://git.drupalcode.org/project/jsonapi_reference/-/merge_requests/25
- 🇬🇧United Kingdom Eli-T Manchester
This also seems to work with the additions to jsonapi_reference_field_widget_info_alter in ✨ Add select list widget Needs work and #3314975: Add radio buttons widget → .
- 🇬🇧United Kingdom Eli-T Manchester
Awesome - that's merged in. Let's get the two widget issues complete, update the documentation and get a new release out!
Automatically closed - issue fixed for 2 weeks with no activity.