protected function CommercePluginEntityFormBase::protectPluginIdElement in Commerce Core 8.2
Protects the plugin'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 plugin config entity's ID property.
Parameters
array $form: The completely built plugin entity form array.
Return value
array The updated plugin entity form array.
File
- src/
Form/ CommercePluginEntityFormBase.php, line 24
Class
Namespace
Drupal\commerce\FormCode
protected function protectPluginIdElement(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;
}