Problem/Motivation
Forms with States API started to behave strange after updating to PHP8.
I was able to track it back to the following code:
{%
set classes = [
(has_parent and ('form-actions' in attributes.class|keys or 'form-actions' in attributes.class)) ? 'js-form-wrapper',
(has_parent and ('form-actions' in attributes.class|keys or 'form-actions' in attributes.class)) ? 'form-wrapper',
]
%}
On PHP7 the conditionals always evaluate to TRUE, even if there is no `form-actions` class or key, so the needed classes are added.
On PHP8 this is not the case anymore, so the classes are missing.
Thus, states API gets confused and instead of hiding the correct container, it was hiding the first parent element with `js-form-wrapper` class.
Proposed resolution
If/since this always evaluates to TRUE, and no issue was reported about it until now, it can be safely reverted to the way it is in core container.html.twig:
{%
set classes = [
has_parent ? 'js-form-wrapper',
has_parent ? 'form-wrapper',
]
%}
Remaining tasks
Check if there is a reason for these conditionals and if so, implement it properly on PHP8. Otherwise revert to default.
User interface changes
None.
API changes
None.
Data model changes
None.