function VocabularyForm::buildEntity

Same name and namespace in other branches
  1. 10 core/modules/taxonomy/src/VocabularyForm.php \Drupal\taxonomy\VocabularyForm::buildEntity()

Overrides EntityForm::buildEntity

File

core/modules/taxonomy/src/VocabularyForm.php, line 48

Class

VocabularyForm
Base form for vocabulary edit forms.

Namespace

Drupal\taxonomy

Code

public function buildEntity(array $form, FormStateInterface $form_state) {
    
    /** @var \Drupal\taxonomy\VocabularyInterface $entity */
    $entity = parent::buildEntity($form, $form_state);
    // The description cannot be an empty string.
    if (trim($form_state->getValue('description')) === '') {
        $entity->set('description', NULL);
    }
    return $entity;
}

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