FormTestTableSelectMultipleTrueForm.php 886 Bytes
Newer Older
1 2 3 4
<?php

namespace Drupal\form_test\Form;

5 6
use Drupal\Core\Form\FormStateInterface;

7 8 9 10 11
/**
 * Builds a form to test table select with '#multiple' as TRUE.
 *
 * @internal
 */
12 13 14 15 16 17 18 19 20 21 22 23
class FormTestTableSelectMultipleTrueForm extends FormTestTableSelectFormBase {

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

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

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

}