function BundleEntityFormBase::protectBundleIdElement

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/BundleEntityFormBase.php \Drupal\Core\Entity\BundleEntityFormBase::protectBundleIdElement()
  2. 8.9.x core/lib/Drupal/Core/Entity/BundleEntityFormBase.php \Drupal\Core\Entity\BundleEntityFormBase::protectBundleIdElement()
  3. 10 core/lib/Drupal/Core/Entity/BundleEntityFormBase.php \Drupal\Core\Entity\BundleEntityFormBase::protectBundleIdElement()

Protects the bundle entity's ID property's form element against changes.

This method is assumed to be called on a completely built entity form, including a form element for the bundle config entity's ID property.

Parameters

array $form: The completely built entity bundle form array.

Return value

array The updated entity bundle form array.

4 calls to BundleEntityFormBase::protectBundleIdElement()
BlockContentTypeForm::form in core/modules/block_content/src/BlockContentTypeForm.php
Gets the actual form array to be built.
NodeTypeForm::form in core/modules/node/src/NodeTypeForm.php
Gets the actual form array to be built.
ShortcutSetForm::form in core/modules/shortcut/src/ShortcutSetForm.php
Gets the actual form array to be built.
VocabularyForm::form in core/modules/taxonomy/src/VocabularyForm.php
Gets the actual form array to be built.

File

core/lib/Drupal/Core/Entity/BundleEntityFormBase.php, line 22

Class

BundleEntityFormBase
Class BundleEntityFormBase is a base form for bundle config entities.

Namespace

Drupal\Core\Entity

Code

protected function protectBundleIdElement(array $form) {
    $entity = $this->getEntity();
    $id_key = $entity->getEntityType()
        ->getKey('id');
    assert(isset($form[$id_key]));
    $element =& $form[$id_key];
    // Make sure the element is not accidentally re-enabled if it has already
    // been disabled.
    if (empty($element['#disabled'])) {
        $element['#disabled'] = !$entity->isNew();
    }
    return $form;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.