- Issue created by @thomas.frobieter
- Issue was unassigned.
- Status changed to Closed: works as designed
over 1 year ago 3:31pm 2 November 2023 - 🇩🇪Germany Anybody Porta Westfalica
Looking at the code where we're using the actions type:
$build['homebox_actions_general'] = [ '#type' => 'actions', '#weight' => -100, 'back_button' => $this->buildBackButton($entity), '#attributes' => [ 'class' => [ 'container-inline', 'homebox-actions', 'homebox-actions--general', 'homebox-actions--general-personalize', ], ], ];
and the docs:
https://www.drupal.org/docs/8/theming-drupal-8/using-attributes-in-templ... →
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Template%...I think we're doing it right. Still I'm not 100% sure.
So this is maybe what you want:
if(is_array($variables['#attributes']['class]) && in_array('homebox-actions', $variables['#attributes']['class])) { ... }
Still I don't think it's the right way to add a button. Correct would be to use a hook_form_alter() here I guess. But that's a different topic.
Closing this for now until we find other cases where #attributes are not properly handled.