3 namespace Drupal\test_page_test\Form;
5 use Drupal\Core\Form\FormBase;
6 use Drupal\Core\Form\FormStateInterface;
9 * Defines a test form for testing assertions.
11 class TestForm extends FormBase {
16 public function buildForm(array $form, FormStateInterface $form_state) {
17 $form['test_table'] = [
19 '#header' => ['Column 1', 'Column 2', 'Column 3'],
21 'col_1' => ['#plain_text' => 'foo'],
22 'col_2' => ['#plain_text' => 'bar'],
23 'col_3' => ['#plain_text' => 'baz'],
26 'col_1' => ['#plain_text' => 'one'],
27 'col_2' => ['#plain_text' => 'two'],
28 'col_3' => ['#plain_text' => 'three'],
33 '#type' => 'textfield',
35 '#default_value' => 'Test name',
38 $form['checkbox_enabled'] = [
39 '#type' => 'checkbox',
40 '#title' => 'Checkbox enabled',
41 '#default_value' => TRUE,
44 $form['checkbox_disabled'] = [
45 '#type' => 'checkbox',
46 '#title' => 'Checkbox disabled',
47 '#default_value' => FALSE,
50 $form['description'] = [
51 '#type' => 'textfield',
52 '#title' => 'Description',
53 '#default_value' => '',
58 '#title' => 'Options',
64 '#default_value' => 2,
67 $form['duplicate_button'] = [
69 '#name' => 'duplicate_button',
70 '#value' => 'Duplicate button 1',
73 $form['duplicate_button_2'] = [
75 '#name' => 'duplicate_button',
76 '#value' => 'Duplicate button 2',
79 $form['test_textarea_with_newline'] = [
80 '#type' => 'textarea',
81 '#title' => 'Textarea with newline',
82 '#default_value' => "Test text with\nnewline",
87 '#value' => $this->t('Save'),
96 public function getFormId() {
97 return 'test_page_form';
103 public function submitForm(array &$form, FormStateInterface $form_state) {
104 // Empty on purpose, we just want to test the rendered form elements.