function FormStateTest::testFormErrorsDuringSubmission
Tests that form errors during submission throw an exception.
@legacy-covers ::setErrorByName
File
-
core/
tests/ Drupal/ Tests/ Core/ Form/ FormStateTest.php, line 136
Class
Namespace
Drupal\Tests\Core\FormCode
public function testFormErrorsDuringSubmission() : void {
$form_state = new FormState();
$form_state->setValidationComplete();
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Form errors cannot be set after form validation has finished.');
$form_state->setErrorByName('test', 'message');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.