function TriggeringElementProgrammedTest::testLimitValidationErrors
Tests that #limit_validation_errors of the only submit button takes effect.
File
- 
              core/tests/ Drupal/ KernelTests/ Core/ Form/ TriggeringElementProgrammedTest.php, line 71 
Class
- TriggeringElementProgrammedTest
- Tests detection of triggering_element for programmed form submissions.
Namespace
Drupal\KernelTests\Core\FormCode
public function testLimitValidationErrors() : void {
  // Programmatically submit the form.
  $form_state = new FormState();
  $form_state->setValue('section', 'one');
  $form_builder = $this->container
    ->get('form_builder');
  $form_builder->submitForm($this, $form_state);
  // Verify that only the specified section was validated.
  $errors = $form_state->getErrors();
  $this->assertTrue(isset($errors['one']), "Section 'one' was validated.");
  $this->assertFalse(isset($errors['two']), "Section 'two' was not validated.");
  // Verify that there are only values for the specified section.
  $this->assertTrue($form_state->hasValue('one'), "Values for section 'one' found.");
  $this->assertFalse($form_state->hasValue('two'), "Values for section 'two' not found.");
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
