I know how to add a class to a form element and how to add a form submission button, but there are classes that are automatically added to these buttons in my Drupal 8 install.
The form I am editing has two buttons, a submit and a skip button; both the buttons look the same. I would like to add a visual clue to the difference between the buttons. The buttons get an automatic btn-primary
class but I want the skip button to have a btn-outline-primary
class. If I add that class with '#attributes' => ['class' => ['btn-outline-primary']]
, the class gets added, but the btn-primary
class is still part of the button. The combination of those two classes makes the button text the same color as the button background color, and thus invisible unless you hover over the button.
Is there a way to perhaps not include the button in the template, for example {{ form.actions.skip }}
but more verbose? In the sense that takes over some of the Drupal 8 automation?
<button class="btn btn-outline-primary">{{from.actions.skip.something}}</button>
btn-primary
. Possibly a base theme. Then you could implement your own hook to remove the class again.{{ form.actions.skip.attribute.removeClass('btn-primary') }}
? Because that doesn't work The button is gone If I try that..