function BlockContentTypeForm::copyFormValuesToEntity

Same name and namespace in other branches
  1. 10 core/modules/block_content/src/BlockContentTypeForm.php \Drupal\block_content\BlockContentTypeForm::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/block_content/src/BlockContentTypeForm.php, line 98

Class

BlockContentTypeForm
The block content type entity form.

Namespace

Drupal\block_content

Code

protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {
  // An empty description violates config schema.
  if (trim($form_state->getValue('description', '')) === '') {
    $form_state->unsetValue('description');
  }
  parent::copyFormValuesToEntity($entity, $form, $form_state);
}

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