Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By tim.plunkett on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
In previous versions of Drupal, when calling form_set_error()
and form_error()
:
- During validation would prevent submission, mark the offending element, and use
drupal_set_message()
to display an error message. - During submission would only use
drupal_set_message()
to display an error message, and the element would not be marked in any way.
In Drupal 8, calling form_set_error()
and form_error()
(now FormStateInterface::setErrorByName()
and FormStateInterface::setError()
, respectively) will only have an effect during validation.
Calling them during submission will do nothing. Those instances should be replaced by a drupal_set_message()
call directly.
Impacts:
Module developers