Summary

Convert deprecated @FieldWidget annotations to PHP 8 #[FieldWidget] attributes for Drupal 11 compatibility. Annotation-based plugin discovery is removed in Drupal 11, so the widgets are not discovered
at runtime despite the info.yml declaring ^11 support.

Changes required

  1. src/Plugin/Field/FieldWidget/SelectStringTextfieldWidget.php — Convert @FieldWidget annotation to #[FieldWidget] attribute
  2. src/Plugin/Field/FieldWidget/SelectStringTextareaWidget.php — Convert @FieldWidget annotation to #[FieldWidget] attribute
  3. src/Plugin/Field/FieldWidget/SelectFormattedTextfieldWidget.php — Convert @FieldWidget annotation to #[FieldWidget] attribute
  4. src/Plugin/Field/FieldWidget/SelectFormattedTextareaWidget.php — Convert @FieldWidget annotation to #[FieldWidget] attribute
  5. src/WidgetHelper.php — Replace list($key, $value) with [$key, $value] array destructuring (minor cleanup)

All four widget files need:

  • Add use Drupal\Core\Field\Attribute\FieldWidget;
  • Add use Drupal\Core\StringTranslation\TranslatableMarkup;
  • Replace @FieldWidget(...) docblock with #[FieldWidget(...)] attribute
  • Replace @Translation("...") with new TranslatableMarkup('...')

Safe for all supported versions — attribute discovery works in Drupal 10.2+, and core_version_requirement already requires ^10.3.

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

andyg5000 created an issue. See original summary.

andyg5000’s picture

Status: Active » Needs review

  • mably committed fba7f7ec on 2.x authored by andyg5000
    task: #3582703 Remaining fixes for Drupal 11 Compatiblity
    
    By: andyg5000
    
mably’s picture

Status: Needs review » Fixed

Merged. Thanks @andyg5000!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.