You are here

public function ThunderTermForm::form in Thunder 8.5

Same name and namespace in other branches
  1. 8.2 modules/thunder_taxonomy/src/ThunderTermForm.php \Drupal\thunder_taxonomy\ThunderTermForm::form()
  2. 8.3 modules/thunder_taxonomy/src/ThunderTermForm.php \Drupal\thunder_taxonomy\ThunderTermForm::form()
  3. 8.4 modules/thunder_taxonomy/src/ThunderTermForm.php \Drupal\thunder_taxonomy\ThunderTermForm::form()
  4. 6.0.x modules/thunder_taxonomy/src/ThunderTermForm.php \Drupal\thunder_taxonomy\ThunderTermForm::form()
  5. 6.1.x modules/thunder_taxonomy/src/ThunderTermForm.php \Drupal\thunder_taxonomy\ThunderTermForm::form()

Gets the actual form array to be built.

Overrides TermForm::form

See also

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

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

File

modules/thunder_taxonomy/src/ThunderTermForm.php, line 16

Class

ThunderTermForm
Base for handler for taxonomy term edit forms.

Namespace

Drupal\thunder_taxonomy

Code

public function form(array $form, FormStateInterface $form_state) {
  $form = parent::form($form, $form_state);

  // Create sidebar group.
  $form['advanced'] = [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'entity-meta',
      ],
    ],
    '#weight' => 99,
  ];

  // Use the same form like node edit.
  $form['#theme'] = [
    'node_edit_form',
  ];
  $form['#attached']['library'][] = 'seven/node-form';

  // Move relations into sidebar.
  $form['relations']['#group'] = 'advanced';

  // Move pathauto into sidebar.
  $term = $form_state
    ->getFormObject()
    ->getEntity();
  $form['path_settings'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('URL path settings'),
    '#open' => !empty($form['path']['widget'][0]['alias']['#value']),
    '#group' => 'advanced',
    '#access' => !empty($form['path']['#access']) && $term
      ->hasField('path') && $term
      ->get('path')
      ->access('edit'),
    '#attributes' => [
      'class' => [
        'path-form',
      ],
    ],
    '#attached' => [
      'library' => [
        'path/drupal.path',
      ],
    ],
    '#weight' => 30,
  ];
  $form['path']['#group'] = 'path_settings';
  return $form;
}