SessionTestForm.php in Zircon Profile 8
File
core/modules/system/tests/modules/session_test/src/Form/SessionTestForm.php
View source
<?php
namespace Drupal\session_test\Form;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class SessionTestForm extends FormBase {
public function getFormId() {
return 'session_test_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['input'] = array(
'#type' => 'textfield',
'#title' => 'Input',
'#required' => TRUE,
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => 'Save',
);
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
drupal_set_message(SafeMarkup::format('Ok: @input', array(
'@input' => $form_state
->getValue('input'),
)));
}
}