Almost similar to: https://www.drupal.org/node/1909590

Notice: Undefined index: #icon_position in bootstrap_button() (line 28 of /var/www/sites/alastore.prometdev.com/vendor/drupal/bootstrap/templates/system/button.func.php).

Comments

johnrosswvsu created an issue. See original summary.

johnrosswvsu’s picture

Status: Active » Needs review
StatusFileSize
new620 bytes

The #icon_position index is not always defined so it may be better to put a check first. Will this patch be enough to fix this?

johnrosswvsu’s picture

StatusFileSize
new589 bytes

Or is this a better approach?

markhalliwell’s picture

Status: Needs review » Closed (cannot reproduce)
rosk0’s picture

I'm still seeing this randomly after cache clear. PHP 7.2, Bootstrap 3.26 , Drupal 7.69

tce’s picture

I also see this. Drupal core 7.69, Bootstrap 7.x-3.26. Patch fixes the issue.

markhalliwell’s picture

Category: Bug report » Support request
Status: Closed (cannot reproduce) » Closed (works as designed)

As I stated in #4, this is already added to every element:

https://git.drupalcode.org/project/bootstrap/-/blob/a0cca7d11cfd1b269e2a...

If you're receiving this error, it's likely due to something not using render arrays properly. For example: calling theme functions manually or using #theme instead of using #type as buttons (in D7) are expected to be elements; not theme hooks (that's how core implemented them at the time).

If you get this error, it only means that it's an error with either your custom implementation or some other contrib module.

Please track down that code and fix/file an issue with it instead.

This is not a "bug" in this project, it is designed and implemented the correct way.

tce’s picture

Thanks for your help @markcarver. Your reply lead me to the offending code in a custom module..

<?php
          'close' => array(
            '#theme' => 'button',
            '#value' => t('Close'),
            '#button_type' => 'button',
            '#attributes' => array(
              'class' => array('btn', 'btn-default'),
              'data-dismiss' => 'modal',
            ),
          ),
?>

I changed it to the below and no longer get the error.

<?php
          'close' => array(
            '#markup' => l('&times;', '', array(
              'attributes' => array(
                'class' => array('btn', 'btn-default'),
                'data-dismiss' => 'modal',
              ),
              'fragment' => 'close',
              'html' => TRUE,
            )),
          ),
?>
markhalliwell’s picture

Changing '#theme' => 'button' to '#type' => 'button' should have also worked.