function EntityDisplayModeFormBase::copyFormValuesToEntity

Copies top-level form values to entity properties.

This should not change existing entity properties that are not being edited by this form.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the current form should operate upon.

array $form: A nested array of form elements comprising the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides EntityForm::copyFormValuesToEntity

File

core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php, line 305

Class

EntityDisplayModeFormBase
Provides the generic base class for entity display mode forms.

Namespace

Drupal\field_ui\Form

Code

protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) : void {
  // Config schema dictates that the description value
  // cannot be empty string. So, if it is empty, make it NULL.
  if ($form_state->hasValue('description') && trim($form_state->getValue('description')) === '') {
    $form_state->setValue('description', NULL);
  }
  parent::copyFormValuesToEntity($entity, $form, $form_state);
}

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