You are here

public function BlazyEntityFormBase::form in Blazy 8.2

Gets the actual form array to be built.

Overrides EntityForm::form

See also

\Drupal\Core\Entity\EntityForm::processForm()

\Drupal\Core\Entity\EntityForm::afterBuild()

File

blazy_ui/src/Form/BlazyEntityFormBase.php, line 65

Class

BlazyEntityFormBase
Provides base form for a entity instance configuration form.

Namespace

Drupal\blazy_ui\Form

Code

public function form(array $form, FormStateInterface $form_state) {
  $admin_css = $this->manager
    ->configLoad('admin_css', 'blazy.settings');
  $form['#attributes']['class'][] = 'form--blazy form--slick form--optionset has-tooltip';

  // Change page title for the duplicate operation.
  if ($this->operation == 'duplicate') {
    $form['#title'] = $this
      ->t('<em>Duplicate %name optionset</em>: @label', [
      '%name' => static::$niceName,
      '@label' => $this->entity
        ->label(),
    ]);
    $this->entity = $this->entity
      ->createDuplicate();
  }

  // Change page title for the edit operation.
  if ($this->operation == 'edit') {
    $form['#title'] = $this
      ->t('<em>Edit %name optionset</em>: @label', [
      '%name' => static::$niceName,
      '@label' => $this->entity
        ->label(),
    ]);
  }

  // Attach Slick admin library.
  if ($admin_css && $this->manager
    ->getModuleHandler()
    ->moduleExists('slick_ui')) {
    $form['#attached']['library'][] = 'slick_ui/slick.admin.vtabs';
  }
  return parent::form($form, $form_state);
}