Stable9 form-element template misses form-type-* class

Created on 8 August 2023, over 1 year ago
Updated 2 October 2023, about 1 year ago

Problem/Motivation

Stable9's form-element template doesn't add the form-type-* class which is used by many contrib modules in CSS and JS selectors.
This is how the classes variable is set in the starterkit_theme/form-element.html.twig

{%
  set classes = [
    'js-form-item',
    'form-item',
    'js-form-type-' ~ type|clean_class,
    'form-type-' ~ type|clean_class,      <--- FORM TYPE IS ADDED HERE.
    'js-form-item-' ~ name|clean_class,
    'form-item-' ~ name|clean_class,
    title_display not in ['after', 'before'] ? 'form-no-label',
    disabled == 'disabled' ? 'form-disabled',
    errors ? 'form-item--error',
  ]
%}

This is how the classes variable is set in the stable9/form-element.html.twig

{%
  set classes = [
    'js-form-item',
    'form-item',
    'js-form-type-' ~ type|clean_class,
    'form-item-' ~ name|clean_class,
    'js-form-item-' ~ name|clean_class,
    title_display not in ['after', 'before'] ? 'form-no-label',
    disabled == 'disabled' ? 'form-disabled',
    errors ? 'form-item--error',
  ]
%}

Steps to reproduce

Build a form and inspect its elements. No elements have the form-type- class related to its type.

Proposed resolution

Add the 'form-type-' ~ type|clean_class, snippet to the classes variable:

{%
  set classes = [
    'js-form-item',
    'form-item',
    'form-type-' ~ type|clean_class,
    'js-form-type-' ~ type|clean_class,
    'form-item-' ~ name|clean_class,
    'js-form-item-' ~ name|clean_class,
    title_display not in ['after', 'before'] ? 'form-no-label',
    disabled == 'disabled' ? 'form-disabled',
    errors ? 'form-item--error',
  ]
%}

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Fixed

Version

11.0 🔥

Component

Stable 9 theme

Created by

🇧🇷Brazil andre.bonon

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024