Problem/Motivation

The autocomplete widget is not very intuitive when selecting taxonomy terms.
It would be useful to also have a widget with radio buttons.

Proposed resolution

OptionsButtonsWidget could be extended to add a widget doing this.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

prudloff created an issue. See original summary.

prudloff’s picture

Status: Active » Needs review
eli-t’s picture

Status: Needs review » Needs work

Awesome stuff.

I've given this a test and it seems to do exactly what you want here, and I think this is a great addition to the module.

However there are some coding standard issues in TypedResourceObjectRadioWidget.php - if you can fix those then I'll gladly merge and issue a new release.

Would you be willing to add it to the new 2.0.x branch too? I envisage that to be where the bulk of additions are done in future.

Thanks so much for contributing!

eli-t’s picture

Actually, with respect to 2.0.x branch, there is some work in progress I need to complete #3311240: New 2.0.x branch for PHP 8.1 / Drupal 9/10 and merge in before we should put this in. So let's not worry about that yet.

eli-t’s picture

Version: 8.x-1.0-alpha3 » 2.0.x-dev

I'm not going to add any more functionality to the 8.x-1.x branch so moving this issue to 2.0.x and creating a new branch/MR off that.

eli-t’s picture

Status: Needs work » Needs review
eli-t’s picture

eli-t’s picture

Status: Needs review » Postponed
arousseau’s picture

This will need an update to reflect changes made in #3441052: Options using the same "search attribute"'s value are not all available if/when that lands.

eli-t’s picture

Status: Postponed » Needs work

@arousseau this now seems to work with the now merged change from #3441052, but needs the PHPCS issues raised by the CI to be fixed before it can be merged.

arousseau’s picture

Thank you @eli-t

I think we can avoid adding a dedicated widget here !

I created #3474619: Use OptionsProviderInterface to allow options widgets usage to handle adding the OptionsProviderInterface implementation 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 radio buttons :

$info['options_buttons']['field_types'][] = 'typed_resource_object';

arousseau changed the visibility of the branch 3314975-Add_options_buttons_support_2_0_x to hidden.

arousseau changed the visibility of the branch 3314975-Add_options_buttons_support_2_0_x to active.

arousseau changed the visibility of the branch 3314975-add_radio_buttons_widget_2_0_x to hidden.

arousseau’s picture

I created a new branch + MR for this simple addition. It should be good to go!

eli-t’s picture

Status: Needs work » Reviewed & tested by the community

  • arousseau committed 2fc4397d on 2.0.x
    Issue #3314975: Added options_buttons widget support.
    
eli-t’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.