EditForm::buildForm

public EditForm::buildForm(array $form, FormStateInterface $form_state, $pid = NULL)

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 PathFormBase::buildForm

File

core/modules/path/src/Form/EditForm.php, line 30

Class

EditForm
Provides the path edit form.

Namespace

Drupal\path\Form

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public function buildForm(array $form, FormStateInterface $form_state, $pid = NULL) {
  $form = parent::buildForm($form, $form_state, $pid);
 
  $form['#title'] = $this->path['alias'];
  $form['pid'] = array(
    '#type' => 'hidden',
    '#value' => $this->path['pid'],
  );
 
  $url = new Url('path.delete', array(
    'pid' => $this->path['pid'],
  ));
 
  if ($this->getRequest()->query->has('destination')) {
    $url->setOption('query', $this->getDestinationArray());
  }
 
  $form['actions']['delete'] = array(
    '#type' => 'link',
    '#title' => $this->t('Delete'),
    '#url' => $url,
    '#attributes' => array(
      'class' => array('button', 'button--danger'),
    ),
  );
 
  return $form;
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.