3 namespace Drupal\Core\Entity;
6 * Class BundleEntityFormBase is a base form for bundle config entities.
8 class BundleEntityFormBase extends EntityForm {
11 * Protects the bundle entity's ID property's form element against changes.
13 * This method is assumed to be called on a completely built entity form,
14 * including a form element for the bundle config entity's ID property.
17 * The completely built entity bundle form array.
20 * The updated entity bundle form array.
22 protected function protectBundleIdElement(array $form) {
23 $entity = $this->getEntity();
24 $id_key = $entity->getEntityType()->getKey('id');
25 assert('isset($form[$id_key])');
26 $element = &$form[$id_key];
28 // Make sure the element is not accidentally re-enabled if it has already
30 if (empty($element['#disabled'])) {
31 $element['#disabled'] = !$entity->isNew();