function ElementsTableSelectTest::testMultipleTrueOptionChecker
Tests error handling for invalid tableselect values with checkboxes.
File
- 
              core/modules/ system/ tests/ src/ Functional/ Form/ ElementsTableSelectTest.php, line 159 
Class
- ElementsTableSelectTest
- Tests the tableselect form element for expected behavior.
Namespace
Drupal\Tests\system\Functional\FormCode
public function testMultipleTrueOptionChecker() : void {
  [$header, $options] = Callbacks::tableselectGetData();
  $form['tableselect'] = [
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $options,
  ];
  // Test with a valid value.
  [, , $errors] = $this->formSubmitHelper($form, [
    'tableselect' => [
      'row1' => 'row1',
    ],
  ]);
  $this->assertFalse(isset($errors['tableselect']), 'Option checker allows valid values for checkboxes.');
  // Test with an invalid value.
  [, , $errors] = $this->formSubmitHelper($form, [
    'tableselect' => [
      'non_existing_value' => 'non_existing_value',
    ],
  ]);
  $this->assertTrue(isset($errors['tableselect']), 'Option checker disallows invalid values for checkboxes.');
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
