SessionTestForm.php

Same filename and directory in other branches
  1. 9 core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php
  2. 8.9.x core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php
  3. 10 core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php

Namespace

Drupal\session_test\Form

File

core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php

View source
<?php

namespace Drupal\session_test\Form;

use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

/**
 * Form controller for the test config edit forms.
 *
 * @internal
 */
class SessionTestForm extends FormBase {
    
    /**
     * {@inheritdoc}
     */
    public function getFormId() {
        return 'session_test_form';
    }
    
    /**
     * {@inheritdoc}
     */
    public function buildForm(array $form, FormStateInterface $form_state) {
        $form['input'] = [
            '#type' => 'textfield',
            '#title' => 'Input',
            '#required' => TRUE,
        ];
        $form['actions'] = [
            '#type' => 'actions',
        ];
        $form['actions']['submit'] = [
            '#type' => 'submit',
            '#value' => 'Save',
        ];
        return $form;
    }
    
    /**
     * {@inheritdoc}
     */
    public function submitForm(array &$form, FormStateInterface $form_state) {
        $this->messenger()
            ->addStatus(new FormattableMarkup('Ok: @input', [
            '@input' => $form_state->getValue('input'),
        ]));
    }

}

Classes

Title Deprecated Summary
SessionTestForm Form controller for the test config edit forms.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.