Problem/Motivation

When using the "Smart form descriptions (via Tooltips)" feature, if an element's '#disabled' attribute is set to FALSE (e.g. through hook_form_alter), the tooltip on that element is disabled. This is due to a bug in includes/common.inc, line 86:

 // Ignore if the target element is #disabled.
 || isset($target['#disabled'])

Bootstrap treats any element where the '#disabled' attribute exists as a disabled element, regardless of the value of that attribute.

According to the D7 Form API reference, FALSE is a valid value here. Bootstrap shouldn't disable the tooltip if the '#disabled' attribute is set to FALSE.

Steps to reproduce

  1. In the Bootstrap theme settings , enable JavaScript tooltips and "Smart form descriptions (via Tooltips)". (These should be enabled by default.)
  2. Use the following code in a custom module file replicate this bug on the default login form, which should have descriptions on both the Username and Password fields:
    function MYMODULE_form_user_login_alter(&$form, &$form_state, $form_id){
      $form['name']['#disabled'] = FALSE;
    }
  3. Observe that on the Username field, the tooltip is disabled and the field's description is printed beneath the field, as if the tooltip were disabled via '#smart_description' => FALSE. The Password field, which has not been changed, should render the tooltip as expected.

Proposed resolution

In includes/common.inc, check the value of $target['#disabled'] before disabling tooltips on that field. (See patch below.)

CommentFileSizeAuthor
#2 form_tooltips-3187727-2.patch580 byteselibyrd

Comments

elibyrd created an issue. See original summary.

elibyrd’s picture

Status: Active » Needs review
StatusFileSize
new580 bytes

Attached patch solved the issue on my local site, while still disabling tooltips on form elements that where '#disabled' = TRUE.

elibyrd’s picture

Issue summary: View changes

  • markhalliwell committed 1a3de07 on 7.x-3.x authored by elibyrd
    Issue #3187727 by elibyrd: Smart description tooltips disabled when...
markhalliwell’s picture

Version: 7.x-3.x-dev » 8.x-3.x-dev
Status: Needs review » Fixed

  • markhalliwell committed 0a53b15 on 8.x-3.x
    Issue #3187727 by elibyrd, markhalliwell: Smart description tooltips...

  • markhalliwell committed 0a53b15 on 8.x-4.x
    Issue #3187727 by elibyrd, markhalliwell: Smart description tooltips...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.