You are here

protected function TagFormBase::copyFormValuesToEntity in Extensible BBCode 8.3

Same name and namespace in other branches
  1. 4.0.x src/Form/TagFormBase.php \Drupal\xbbcode\Form\TagFormBase::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

1 call to TagFormBase::copyFormValuesToEntity()
TagForm::copyFormValuesToEntity in src/Form/TagForm.php
Copies top-level form values to entity properties
1 method overrides TagFormBase::copyFormValuesToEntity()
TagForm::copyFormValuesToEntity in src/Form/TagForm.php
Copies top-level form values to entity properties

File

src/Form/TagFormBase.php, line 191

Class

TagFormBase
Base form for custom tags.

Namespace

Drupal\xbbcode\Form

Code

protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) : void {
  parent::copyFormValuesToEntity($entity, $form, $form_state);
  assert($entity instanceof TagInterface);
  $attached = [];
  if ($libraries = trim($form_state
    ->getValue([
    'attached',
    'library',
  ]))) {
    $attached['library'] = explode("\n", $libraries);
  }
  $entity
    ->set('attached', $attached);
}