Use class "active" for active plan variant radio instead of #prefix / #suffix div wrapper

Created on 26 February 2024, about 1 year ago
Updated 26 March 2024, about 1 year ago

Problem/Motivation

In the change plan variant form, we're marking the active plan variant.

Currently we're doing it like this:

      $form['planvariant'][$activePlanVariantMachineName]['#prefix'] = '<div class="active">';
      $form['planvariant'][$activePlanVariantMachineName]['#suffix'] = '</div>';

(https://git.drupalcode.org/project/billwerk_subscriptions/-/blob/1.x/mod...)

@thomas.frobieter pointed out, that a class "active" on the radio might be the more correct choice.
So we could do it like this instead:

$form['planvariant'][$activePlanVariantMachineName]['#attributes']['class'][] = 'active';

But note, that then the "active" is only present on the radio form element!

PS:
I found another option for the second MR:

$form['planvariant'][$activePlanVariantMachineName]['#wrapper_attributes']['class'][] = 'active';

We could also combine both.

What's better and more flexible?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024