PathFormBase::submitForm

public PathFormBase::submitForm(array &$form, FormStateInterface $form_state)

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

core/modules/path/src/Form/PathFormBase.php, line 203

Class

PathFormBase
Provides a base class for path add/edit forms.

Namespace

Drupal\path\Form

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public function submitForm(array &$form, FormStateInterface $form_state) {
  // Remove unnecessary values.
  $form_state->cleanValues();
 
  $pid = $form_state->getValue('pid', 0);
  $source = $form_state->getValue('source');
  $alias = $form_state->getValue('alias');
  // Language is only set if language.module is enabled, otherwise save for all
  // languages.
  $langcode = $form_state->getValue('langcode', LanguageInterface::LANGCODE_NOT_SPECIFIED);
 
  $this->aliasStorage->save($source, $alias, $langcode, $pid);
 
  drupal_set_message($this->t('The alias has been saved.'));
  $form_state->setRedirect('path.admin_overview');
}
doc_Drupal
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.