You are here

public function SynonymForm::buildForm in Search API Synonym 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

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

Return value

array The form structure.

Overrides EntityForm::buildForm

File

src/Form/SynonymForm.php, line 18

Class

SynonymForm
Form controller for Synonym edit forms.

Namespace

Drupal\search_api_synonym\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {

  // Trim whitespaces from synonyms and save back into the form state.

  /* @var \Drupal\search_api_synonym\SynonymInterface $entity */
  $entity = $this->entity;
  $synonyms = $entity
    ->getSynonymsFormatted();
  if (!empty($synonyms)) {
    $entity
      ->setSynonyms($synonyms);
  }
  return parent::buildForm($form, $form_state);
}