You are here

public function AbstractFieldThirdPartySettingsFormEvent::addElements in Hook Event Dispatcher 3.x

Same name and namespace in other branches
  1. 8.2 modules/field_event_dispatcher/src/Event/Field/AbstractFieldThirdPartySettingsFormEvent.php \Drupal\field_event_dispatcher\Event\Field\AbstractFieldThirdPartySettingsFormEvent::addElements()

Add third-party form elements to the form.

Alters the form structure so that each module's third-party form elements are correctly nested only under their module machine names.

Parameters

string $moduleName: The machine name of the module to add the third-party form elements for.

array $newElements: An array containing the third-party form elements to add.

See also

\Drupal\field_event_dispatcher\EventSubscriber\Form\FormEntityViewDisplayEditAlterEventSubscriber::formAlter()

File

modules/field_event_dispatcher/src/Event/Field/AbstractFieldThirdPartySettingsFormEvent.php, line 110

Class

AbstractFieldThirdPartySettingsFormEvent
Class AbstractFieldThirdPartySettingsFormEvent.

Namespace

Drupal\field_event_dispatcher\Event\Field

Code

public function addElements(string $moduleName, array $newElements) : void {
  $this->elements = NestedArray::mergeDeep($this->elements, [
    // Nest the new elements under the module's machine name for our form
    // alter event subscriber.
    $moduleName => $newElements,
  ]);
}