}
// Count how often the form is constructed.
$_SESSION['constructions']++;
- drupal_set_message("Form constructions: " . $_SESSION['constructions']);
+ $this->messenger()->addStatus("Form constructions: " . $_SESSION['constructions']);
$form['title'] = [
'#type' => 'textfield',
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- drupal_set_message("Title: " . Html::escape($form_state->getValue('title')));
- drupal_set_message("Form constructions: " . $_SESSION['constructions']);
+ $this->messenger()->addStatus("Title: " . Html::escape($form_state->getValue('title')));
+ $this->messenger()->addStatus("Form constructions: " . $_SESSION['constructions']);
if ($form_state->has(['thing', 'changed'])) {
- drupal_set_message("The thing has been changed.");
+ $this->messenger()->addStatus("The thing has been changed.");
}
$form_state->setRedirect('<front>');
}