Commit dbb5457c authored by webchick's avatar webchick

#527804 by sun: Add an alter hook for element_info() to change default values of form elements.

parent 2a6bd603
......@@ -3987,6 +3987,8 @@ function element_info($type) {
$cache[$element_type]['#type'] = $element_type;
}
}
// Allow modules to alter the element type defaults.
drupal_alter('element_info', $cache);
}
return $cache[$type];
......
......@@ -115,6 +115,24 @@ function hook_elements() {
return $type;
}
/**
* Alter the element type information returned from modules.
*
* A module may implement this hook in order to alter the element type defaults
* defined by a module.
*
* @param &$type
* All element type defaults as collected by hook_elements().
*
* @see hook_elements()
*/
function hook_element_info_alter(&$type) {
// Decrease the default size of textfields.
if (isset($type['textfield']['#size'])) {
$type['textfield']['#size'] = 40;
}
}
/**
* Perform cleanup tasks.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment