getEntity(); // Taxonomy terms do not have an actual fieldset for path settings. // Merge in the defaults. // @todo Impossible to do this in widget, use another solution /* $form['path'] += array( '#type' => 'fieldset', '#title' => $this->t('URL path settings'), '#collapsible' => TRUE, '#collapsed' => empty($form['path']['alias']), '#group' => 'additional_settings', '#attributes' => array( 'class' => array('path-form'), ), '#access' => \Drupal::currentUser()->hasPermission('create url aliases') || \Drupal::currentUser()->hasPermission('administer url aliases'), '#weight' => 30, '#tree' => TRUE, '#element_validate' => array('path_form_element_validate'), );*/ $pattern = \Drupal::service('pathauto.generator')->getPatternByEntity($entity); if (empty($pattern)) { return $element; } if (\Drupal::currentUser()->hasPermission('administer pathauto')) { $description = $this->t('Uncheck this to create a custom alias below. Configure URL alias patterns.', ['@admin_link' => Url::fromRoute('entity.pathauto_pattern.collection')->toString()]); } else { $description = $this->t('Uncheck this to create a custom alias below.'); } $element['pathauto'] = array( '#type' => 'checkbox', '#title' => $this->t('Generate automatic URL alias'), '#default_value' => $entity->path->pathauto, '#description' => $description, '#weight' => -1, ); // Add JavaScript that will disable the path textfield when the automatic // alias checkbox is checked. $element['alias']['#states']['disabled']['input[name="path[' . $delta . '][pathauto]"]'] = array('checked' => TRUE); // Override path.module's vertical tabs summary. $element['alias']['#attached']['library'] = ['pathauto/widget']; return $element; } }