1

Maybe someone knows why when you change the name of the button, its class changes from btn-primary to btn-default. btn-primary only if there is a submit in the button name (Without spaces before or after).

3
  • 1
    Because that's how the bootstrap theme is coded. There's a preprocess function which checks the button label and applies a class based on it.
    – Clive
    Commented Aug 23, 2021 at 14:17
  • Where exactly is this function implemented? Commented Aug 23, 2021 at 14:50
  • 1
    In includes/common.inc (_bootstrap_colorize_button())
    – Clive
    Commented Aug 23, 2021 at 15:17

1 Answer 1

2

Thank you so much for Clive help. As it turned out, the _bootstrap_colorize_button function is responsible for choosing which class will be assigned depending on the label. To add a new word to this function, you need to implement hook_bootstrap_colorize_text_alter(). My code.

function myTheme_bootstrap_colorize_text_alter(array &$texts){
  $texts['contains'][t('Register')] = 'primary';
}

Instead of t ('Register'), you need the word and assign the bootstrap class you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.