Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DefaultSelection.php

function DefaultSelection::validateTargetBundles

Validates a target_bundles element.

File

core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php, line 333

Class

DefaultSelection
Default plugin implementation of the Entity Reference Selection plugin.

Namespace

Drupal\Core\Entity\Plugin\EntityReferenceSelection

Code

public static function validateTargetBundles($element, FormStateInterface $form_state, $form) {
    // If no checkboxes were checked for 'target_bundles', store NULL ("all
    // bundles are referenceable") rather than empty array ("no bundle is
    // referenceable" - typically happens when all referenceable bundles have
    // been deleted).
    if ($form_state->getValue($element['#parents']) === []) {
        $form_state->setValueForElement($element, NULL);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal