summaryrefslogtreecommitdiffstats
path: root/core/modules/system/tests/modules/form_test/src/Form/FormTestTableSelectMultipleTrueForm.php
blob: 1d46d7cc65968c32c07a50188c67bbcde0db5f51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

namespace Drupal\form_test\Form;

use Drupal\Core\Form\FormStateInterface;

/**
 * Builds a form to test table select with '#multiple' as TRUE.
 *
 * @internal
 */
class FormTestTableSelectMultipleTrueForm extends FormTestTableSelectFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return '_form_test_tableselect_multiple_true_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    return $this->tableselectFormBuilder($form, $form_state, ['#multiple' => TRUE]);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $selected = $form_state->getValue('tableselect');
    foreach ($selected as $key => $value) {
      drupal_set_message(t('Submitted: @key = @value', ['@key' => $key, '@value' => $value]));
    }
  }

}