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
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;
}