diff --git a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php
index 5e00f7e..e4f47b2 100644
--- a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php
+++ b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php
@@ -160,6 +160,25 @@ public function isDisplayConfigurable($display_context);
public function getDisplayOptions($display_context);
/**
+ * Returns whether the field can be empty.
+ *
+ * If a field is required, an entity needs to have at least a valid,
+ * non-empty item in that field's FieldItemList in order to pass validation.
+ *
+ * An item is considered empty if its isEmpty() method returns TRUE.
+ * Typically, that is if at least one of its required properties is empty.
+ *
+ * @return bool
+ * TRUE if the field is required.
+ *
+ * @see \Drupal\Core\TypedData\Plugin\DataType\ItemList::isEmpty()
+ * @see \Drupal\Core\Field\FieldItemInterface::isEmpty()
+ * @see \Drupal\Core\TypedData\DataDefinitionInterface:isRequired()
+ * @see \Drupal\Core\TypedData\TypedDataManager::getDefaultConstraints()
+ */
+ public function isRequired();
+
+ /**
* Returns the default value for the field in a newly created entity.
*
* @param \Drupal\Core\Entity\FieldableEntityInterface $entity
diff --git a/core/modules/field_ui/src/Form/FieldConfigEditForm.php b/core/modules/field_ui/src/Form/FieldConfigEditForm.php
index 1cf796e..866ff9a 100644
--- a/core/modules/field_ui/src/Form/FieldConfigEditForm.php
+++ b/core/modules/field_ui/src/Form/FieldConfigEditForm.php
@@ -35,20 +35,18 @@ class FieldConfigEditForm extends EntityForm {
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
- /** @var \Drupal\field\Entity\FieldConfig $field */
- $field = $this->entity;
- $field_storage = $field->getFieldStorageDefinition();
+ $field_storage = $this->entity->getFieldStorageDefinition();
$bundles = $this->entityManager->getBundleInfo($this->entity->getTargetEntityTypeId());
$form_title = $this->t('%field settings for %bundle', array(
- '%field' => $field->getLabel(),
- '%bundle' => $bundles[$field->getTargetBundle()]['label'],
+ '%field' => $this->entity->getLabel(),
+ '%bundle' => $bundles[$this->entity->getTargetBundle()]['label'],
));
$form['#title'] = $form_title;
if ($field_storage->isLocked()) {
$form['locked'] = array(
- '#markup' => $this->t('The field %field is locked and cannot be edited.', array('%field' => $field->getLabel())),
+ '#markup' => $this->t('The field %field is locked and cannot be edited.', array('%field' => $this->entity->getLabel())),
);
return $form;
}
@@ -57,7 +55,7 @@ public function form(array $form, FormStateInterface $form_state) {
$form['label'] = array(
'#type' => 'textfield',
'#title' => $this->t('Label'),
- '#default_value' => $field->getLabel() ?: $field_storage->getName(),
+ '#default_value' => $this->entity->getLabel() ?: $field_storage->getName(),
'#required' => TRUE,
'#weight' => -20,
);
@@ -65,7 +63,7 @@ public function form(array $form, FormStateInterface $form_state) {
$form['description'] = array(
'#type' => 'textarea',
'#title' => $this->t('Help text'),
- '#default_value' => $field->getDescription(),
+ '#default_value' => $this->entity->getDescription(),
'#rows' => 5,
'#description' => $this->t('Instructions to present to the user below this field on the editing form.
Allowed HTML tags: @tags', array('@tags' => $this->displayAllowedTags())) . '
' . $this->t('This field supports tokens.'),
'#weight' => -10,
@@ -74,18 +72,18 @@ public function form(array $form, FormStateInterface $form_state) {
$form['required'] = array(
'#type' => 'checkbox',
'#title' => $this->t('Required field'),
- '#default_value' => $field->isRequired(),
+ '#default_value' => $this->entity->isRequired(),
'#weight' => -5,
);
// Create an arbitrary entity object (used by the 'default value' widget).
$ids = (object) array(
'entity_type' => $this->entity->getTargetEntityTypeId(),
- 'bundle' => $field->getTargetBundle(),
+ 'bundle' => $this->entity->getTargetBundle(),
'entity_id' => NULL
);
$form['#entity'] = _field_create_entity_from_ids($ids);
- $items = $form['#entity']->get($field->getName());
+ $items = $form['#entity']->get($this->entity->getName());
$item = $items->first() ?: $items->appendItem();
// Add field settings for the field type and a container for third party