Closed (fixed)
Project:
JSON:API Reference
Version:
2.0.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Oct 2022 at 16:03 UTC
Updated:
28 Oct 2024 at 10:24 UTC
Jump to comment: Most recent
Comments
Comment #2
prudloff commentedComment #4
prudloff commentedComment #5
eli-tAs #3314975: Add radio buttons widget, I think this is a good addition but we need to fix the coding standards in the new file.
Also
has a copy/pasted reference to radio buttons, presumably from #3314975: Add radio buttons widget.
If we fix those, then we should commit this to both branches.
Comment #6
eli-tNo new features will be added to the 8.x-1.x branch so moving this to 2.0.x
Comment #8
eli-tComment #9
eli-tJust spun this up on the 2.0.x branch to make sure it works, and it seems to work fine.
I think we should add the JSON:API ID to the select list as well as the title though; this info is available when using the autocomplete so that the user can distinguish between multiple pieces of content with the same name.
Comment #10
eli-tThis has also spurred the thought - at the moment in the autocomplete, and also in this MR for the select list, there is configuration for what JSON:API attribute should be considered the title - to either autocomplete against, or display in the select list.
This will always be the same regardless of which widget you are using - it seems to be a fundamental property of the field itself rather than the widget you use to edit it. We should move that to field configuration instead of widget configuration. This also means you wouldn't need to change this setting multiple times if you switched between widgets for a given field.
This doesn't have to be done in this issue but should be done before this issue is merged so we don't have to rework.
Comment #11
eli-tComment #12
eli-tComment #14
arousseau commentedUsing this in one of our project, we ran into a small issue. The order along which the options are displayed by the select list seems to be a bit unpredictable.
This could be easily solved by forcing a sort order on the search attribute. Added a modification to the MR.
Comment #15
eli-tThanks for contributing! I should have time to take a look at this next week.
Comment #16
eli-tNote the issue raised in #10 is now resolved in 2.0.x.
Comment #17
arousseau commentedI reworked this in order to make use of
OptionsProviderInterfaceas explained in\Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsWidgetBaseI tried to stick to the way things are done in core entity_reference field type.
This should allow the use of
hook_options_list_alterto sort the display order of the options too.Comment #18
arousseau commentedI created #3474619: Use OptionsProviderInterface to allow options widgets usage to handle adding the
OptionsProviderInterfaceimplementation to the field type.Once it is merged, we'll only need to add the following to the existing
jsonapi_reference_field_widget_info_alter, to allow for the use of a select list :Comment #19
eli-t@arousseau ❤️
Comment #20
arousseau commentedComment #23
arousseau commentedI created a new branch + MR for this simple addition. It should be good to go!
Comment #24
eli-tComment #26
eli-t