2

I tried "Inline Form Errors" module but it add errors message content after form element. How to add inline form errors with bootstrap tooltip or popovers directly to inputs and selects? Does somebody do something like this?

1 Answer 1

1

Solve this by element pre render callback and ife module.

function _custom_bootstrap_pre_render_input($element) {
    $types = array(
        // Core.
        'password',
        'password_confirm',
        'select',
        'textarea',
        'textfield',
        // Elements module.
        'emailfield',
        'numberfield',
        'rangefield',
        'searchfield',
        'telfield',
        'urlfield',
    );
    if (empty($element['#type']) || !(in_array($element['#type'], $types) || ($element['#type'] === 'file' && empty($element['#managed_file']))) || !isset($element['#id'])) {
        return $element;
    }
    $error = ife_errors('get', $element['#id']);
    if (!empty($error)) {
        $element['#attributes']['class'][] = 'error-tooltip';
        $element['#attributes']['data-content'][] = $error;
    }
    return $element;
}

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.