Change record status: 
Project: 
Introduced in branch: 
10.1.x
Introduced in version: 
Description: 

A new classes state has been added to Conditional Form Fields. This provides the ability to add or remove CSS classes for the target field provided, if the logic provided for the target field is met, with a class sub-array containing the classes to be used.

For example, the following code gives field_test_field_three the classes 'TESTING' and 'TESTINGTWO' when field_test_field_one has the value 'One'. The classes are removed when field_test_field_one does not have the value 'One'.

$form['field_test_field_three']['#states'] = [
  'classes' => [
    'select[name="field_test_field_one"]' => [
      'value' => 'one',
    ],
    'class' => [
      'TESTING',
      'TESTINGTWO',
    ],
  ],
];

The new state is used in the same way that other Conditional Form Fields states are used, and can be used in conjunction with other states.

Impacts: 
Site builders, administrators, editors
Module developers
Themers