FieldHookEvents::WIDGET_SINGLE_ELEMENT_FORM_ALTER not found

Created on 31 October 2022, about 2 years ago
Updated 28 December 2023, 11 months ago

Problem/Motivation

I've attempted to replicate the hook hook_field_widget_form_alter() by using the event FieldHookEvents::WIDGET_SINGLE_ELEMENT_FORM_ALTER.

The relevant part of my code looks like this:

use Drupal\field_event_dispatcher\FieldHookEvents;
use Drupal\core_event_dispatcher\FormHookEvents;

class MyModuleFormEventSubscriber implements EventSubscriberInterface {
  public static function getSubscribedEvents() {
    return [
      FieldHookEvents::WIDGET_SINGLE_ELEMENT_FORM_ALTER => 'fieldWidgetFormAlter',
      FormHookEvents::FORM_ALTER => 'formAlter',
    ];
  }
}

Upon clearing caches I get this error:

Fatal error: Uncaught Error: Class "Drupal\field_event_dispatcher\FieldHookEvents" not found in /var/www/docroot/modules/custom/my_module/src/EventSubscriber/MyModuleFormEventSubscriber.php:24

If I comment out FieldHookEvents::WIDGET_SINGLE_ELEMENT_FORM_ALTER => 'fieldWidgetFormAlter',, FormHookEvents::FORM_ALTER => 'formAlter' works fine, so I don't think this is a problem with my implementation.

Steps to reproduce

Try to use the FieldHookEvents::WIDGET_SINGLE_ELEMENT_FORM_ALTER event.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: works as designed

Version

3.3

Component

Code

Created by

🇺🇸United States maskedjellybean Portland, OR

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024