diff --git a/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php b/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php index 40dbb73..0023a9d 100644 --- a/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php +++ b/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php @@ -52,13 +52,6 @@ public function buildForm(array $form, FormStateInterface $form_state, $field_co $form_state->set('bundle', $field->getTargetBundle()); } - // Forbid access to the form if the field is locked. - if ($field->isLocked()) { - $form['locked'] = array( - '#markup' => $this->t('The field %field is locked and cannot be edited.', array('%field' => $field_config->getLabel())), - ); - } - return parent::buildForm($form, $form_state); } @@ -69,6 +62,17 @@ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $field_label = $form_state->get('field_config')->label(); + + // Forbid access to the form if the field is locked. + $field_storage = $form_state->get('field_config')->getFieldStorageDefinition(); + if ($field_storage->isLocked()) { + $form['locked'] = array( + '#markup' => $this->t('The field %field is locked and cannot be edited.', array('%field' => $field_label)), + ); + + return $form; + } + $form['#title'] = $field_label; $form['#prefix'] = '

' . $this->t('These settings apply to the %field field everywhere it is used. These settings impact the way that data is stored in the database and cannot be changed once data has been created.', array('%field' => $field_label)) . '

';