Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I would like add the class 'panel-primary' to some (not all) panels. I tried to use hook_preprocess_fieldset to add this class but this hook seems not to work with the bootstrap theme. Is there a better or correct way of doing this?
Comments
Comment #2
markhalliwellThis sounds like there could be some logic that may be preventing the class from being added...
However, I think this has more to do with https://drupal-bootstrap.org/api/bootstrap/templates%21bootstrap%21boots...
I'd recommend stepping through and seeing that hook and class are actually being invoked (I think they are).
I think the real issue is because the panel type is being added after (in the template), it takes precedence visually (last class wins).
Try setting
'#panel_type' => 'primary'
for the fieldset in question.Then you won't need a preprocess hook at all.
Comment #3
mike82 CreditAttribution: mike82 commentedHow can I set this if hook_preprocess_fieldset is not called?
For example the commerce checkout pane:
hook_preprocess_fieldset doesn't work for this fieldset. How can I change the style to panel-primary or set #panel_type' => 'primary' ?
Comment #4
markhalliwellUse
hook_preprocess_bootstrap_panel()
or, preferably,hook_form_FORM_ID_alter()
and add it to the form element before it makes its way through the theme system.Comment #5
mike82 CreditAttribution: mike82 commentedThanks,
hook_form_FORM_ID_alter()
works, I was only focussing on preprocess hooks.But
hook_preprocess_bootstrap_panel()
is not called, neither ishook_preprocess_fieldset()
. I think it's strange that both preprocess hooks do not work. I can exclude that this is some caching issue, ashook_preprocess_fieldset()
works fine for other fieldsets. Is it a bug or is there a reason?