3 namespace Drupal\form_test\Form;
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
9 * Form constructor for testing form state persistence.
11 class FormTestStatePersistForm extends FormBase {
16 public function getFormId() {
17 return 'form_test_state_persist';
23 public function buildForm(array $form, FormStateInterface $form_state) {
25 '#type' => 'textfield',
27 '#default_value' => 'DEFAULT',
30 $form_state->set('value', 'State persisted.');
34 '#value' => t('Submit'),
42 public function submitForm(array &$form, FormStateInterface $form_state) {
43 drupal_set_message($form_state->get('value'));
44 $form_state->setRebuild();