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
- In the Bootstrap theme settings , enable JavaScript tooltips and "Smart form descriptions (via Tooltips)". (These should be enabled by default.)
- 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;
}
- 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.)
Comments
Comment #2
elibyrdAttached patch solved the issue on my local site, while still disabling tooltips on form elements that where '#disabled' = TRUE.
Comment #3
elibyrdComment #5
markhalliwell