Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The correct param is $info.
/**
* 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 array $types
* An associative array with structure identical to that of the return value
* of \Drupal\Core\Render\ElementInfoManagerInterface::getInfo().
*
* @see \Drupal\Core\Render\ElementInfoManager
* @see \Drupal\Core\Render\Element\ElementInterface
*/
function hook_element_info_alter(array &$types) {
// Decrease the default size of textfields.
if (isset($types['textfield']['#size'])) {
$types['textfield']['#size'] = 40;
}
}
Perhaps we can use the code example from the test:
http://cgit.drupalcode.org/drupal/tree/core/modules/system/tests/themes/...
Comment | File | Size | Author |
---|---|---|---|
#7 | incorrect-documentation-changed-param-2751923.patch | 1.03 KB | lhuria94 |
#3 | incorrect-documentation-2751923-3.patch | 1.21 KB | mohit_aghera |
Comments
Comment #2
Jeff Burnz CreditAttribution: Jeff Burnz commentedComment #3
mohit_aghera CreditAttribution: mohit_aghera as a volunteer and at Axelerant commentedComment #4
joelpittetThat's neat, the snippet doesn't need the hook? I'd check but I'm on a phone atm. Thanks for the fix.
Comment #5
prateekjain CreditAttribution: prateekjain at Blisstering Solutions commentedPatch looks good. Changing it to RTBC
Comment #6
Jeff Burnz CreditAttribution: Jeff Burnz commentedlooks good, but I note the test doesn't have the type declaration, should we update that also, is it required etc?
Comment #7
lhuria94 CreditAttribution: lhuria94 at Srijan | A Material+ Company commentedYes the snippet doesn't need the hook, updating the patch with required parameter and documentation changes.
Comment #8
joelpittetThank you. That is a nice clear cleanup
Comment #10
joelpittetComment #13
xjmThe patch in #7 does look best to me.
Regarding #6, types are indeed required now, but see the core scope documentation for coding standards for why added data types should not be included in this patch.
Committed 8e04ab6 and pushed to 8.2.x and 8.1.x. Thanks!