/**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     // Hide status checkbox. We have the button.
     $form['status']['#access'] = FALSE;
     // Create sidebar group.
     $form['advanced'] = array('#type' => 'container', '#attributes' => array('class' => array('entity-meta')), '#weight' => 99);
     // Use the same form like node edit.
     $form['#theme'] = array('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'] = array('#type' => 'details', '#title' => 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' => array('class' => array('path-form')), '#attached' => array('library' => array('path/drupal.path')), '#weight' => 30);
     $form['path']['#group'] = 'path_settings';
     // Update callback for status change.
     $form['#entity_builders']['update_status'] = [$this, 'updateStatus'];
     return $form;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $taxonomy_term = $this->entity;
     // Build the bulk of the form from the parent taxonomy term form.
     $form = parent::form($form, $form_state, $taxonomy_term);
     // Set the title and description of the name field.
     $form['name']['#title'] = $this->t('Forum name');
     $form['name']['#description'] = $this->t('Short but meaningful name for this collection of threaded discussions.');
     // Change the description.
     $form['description']['#description'] = $this->t('Description and guidelines for discussions within this forum.');
     // Re-use the weight field.
     $form['weight'] = $form['relations']['weight'];
     // Remove the remaining relations fields.
     unset($form['relations']);
     // Our parent field is different to the taxonomy term.
     $form['parent']['#tree'] = TRUE;
     $form['parent'][0] = $this->forumParentSelect($taxonomy_term->id(), $this->t('Parent'));
     $form['#theme_wrappers'] = array('form__forum');
     $this->forumFormType = $this->t('forum');
     return $form;
 }