Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / system / tests / modules / form_test / src / Form / FormTestStatePersistForm.php
1 <?php
2
3 namespace Drupal\form_test\Form;
4
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
7
8 /**
9  * Form constructor for testing form state persistence.
10  */
11 class FormTestStatePersistForm extends FormBase {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function getFormId() {
17     return 'form_test_state_persist';
18   }
19
20   /**
21    * {@inheritdoc}
22    */
23   public function buildForm(array $form, FormStateInterface $form_state) {
24     $form['title'] = [
25       '#type' => 'textfield',
26       '#title' => 'title',
27       '#default_value' => 'DEFAULT',
28       '#required' => TRUE,
29     ];
30     $form_state->set('value', 'State persisted.');
31
32     $form['submit'] = [
33       '#type' => 'submit',
34       '#value' => t('Submit'),
35     ];
36     return $form;
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public function submitForm(array &$form, FormStateInterface $form_state) {
43     drupal_set_message($form_state->get('value'));
44     $form_state->setRebuild();
45   }
46
47 }