I am using Bootstrap 3 subtheme (7.x-3.1-beta2 ) on Drupal 7 for the administrative backend. It seems that the Bootstrap base theme replaces <input type="submit"> with a <button> element. That breaks the layout of the views backend.

I tried to change this by:

  • copying button.func.php into the subtheme
  • renaming the function according to the subtheme name
  • modifying the output to return <input> instead of <button>

Code in button.func.php

function bootstrap_subtheme_adl_admin_button($variables) {
  $element = $variables['element'];
  $value = $element['#value'];
   if (!empty($element['#icon'])) {
     if ($element['#icon_position'] === 'before') {
       $value = $element['#icon'] . ' ' . $value;
   elseif ($element['#icon_position'] === 'after') {
     $value .= ' ' . $element['#icon'];

return '<input' . drupal_attributes($element['#attributes']) . '>\n';

However, this does not have any visible effect. Any advise?

  • 2
    Did you clear cache?
    – sam2de
    Commented Dec 18, 2014 at 20:18
  • @sam2de of course. Commented Dec 18, 2014 at 20:20
  • Is your function even called at all?
    – Mołot
    Commented Dec 19, 2014 at 10:29
  • @Mołot maybe I am misunderstanding this, but the function is called by the base theme, I am just attempting to overwrite it in the sub theme. In fact, it works fine when I edit the function in the base theme. Commented Dec 19, 2014 at 16:19
  • Ok, but in the subtheme is it executed, but wrong results, or not called at all?
    – Mołot
    Commented Dec 19, 2014 at 16:20

1 Answer 1


If I'm reading the question directly, you've copied button.func.php into your sub-theme, modified the code inside it, and then tried to see if your changes work?

If that's what you did, the problem is that Drupal never sees the code. Fortunately (if that is the problem) the solution is simple: copy the code from that file into your sub-theme's template.php file and make whatever changes are required. Be sure the function is correctly named (i.e. to override theme_button, you'd need themename + button = themename_button()). In your example above, your sub-theme would have to be named 'bootstrap_subtheme_adl_admin' in order for your function to be called even if the code is in the correct file.

Incidentally, the reason the button.func.php file works in the base Bootstrap theme appears to be the theme's registry.inc file.

Basic sub-theme how-to with Bootstrap

  1. Download Bootstrap sub theme into /sites/all/themes; don't bother to enable the theme
  2. Copy bootstrap_subtheme from the /sites/all/themes/bootstrap/bootstrap_subtheme to /sites/all/themes/bootstrap_subtheme
  3. Move /sites/all/themes/bootstrap_subtheme/bootstrap_subtheme.info.starterkit to /sites/all/themes/bootstrap_subtheme/bootstrap_subtheme.info
  4. Enable bootstrap_subtheme

Overriding a theme function implemented by a parent theme

  1. Set up parent and subtheme as described above
  2. Never edit the parent theme in any way
  3. Copy the theme function you want to modify from e.g. /sites/all/themes/bootstrap/theme/system/button.func.php into the file at /sites/all/themes/bootstrap_subtheme/template.php
  4. Change the name of the function in /sites/all/themes/bootstrap_subtheme/template.php from bootstrap_button to bootstrap_subtheme_button
  • Thank you @bhotel for your answer and explanation. I thought so too, however, if I try to declare function bootstrap_subtheme_adl_admin_button($variables) {} in template.php I end up with a white screen of death. I am a bit confused. I really would like to do adjustments like those in the subtheme rather the base theme, but seem not to find out what the correct way of doing this is. Commented Dec 22, 2014 at 14:15
  • Well, the white screen of death means there's a PHP fatal error. Find out from the error log what that error is, and you'll likely have the solution to the problem. Also, please confirm: the machine name of your subtheme is bootstrap_subtheme_adl_admin?
    – bhotel
    Commented Dec 22, 2014 at 19:04
  • oh well, the php error log shows that the issue is that bootstrap_subtheme_adl_admin_button() declared in template.php has been also declared in button.func.php in my subtheme (yes: bootstrap_subtheme_adl_admin is the machine name) - which, yes is correct: I declared the function there, but that didn't work. Now if this is cause of the error, doesn't this indicated that Drupal very well is aware of the code in button.func.php ? Edit: If I remove the function from button.func.php in my sub-theme all is good again. Right. This still bugs me though. Commented Dec 22, 2014 at 20:33
  • That error means the function has been defined with the same name in more than one place. You've either a) renamed the function in the bootstrap parent theme so that it's the same as in your sub theme, or b) you have not renamed the function in your sub theme.
    – bhotel
    Commented Dec 22, 2014 at 21:07
  • The issue was that the function was defined with the same name in template.php and button.func.php - both bootstrap_subtheme_adl_admin_button- in the sub-theme. Still haven't found a solution though. The function doesn't change the output when in template.php nor in button.func.php. The only way it seems to get the correct results is if I overwrite the function in the base theme. I can't wrap my head around it :/ Commented Dec 22, 2014 at 21:40

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.