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/...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jeff Burnz created an issue. See original summary.

Jeff Burnz’s picture

Issue tags: +Novice, +documentation code examples
mohit_aghera’s picture

Status: Active » Needs review
FileSize
1.21 KB
joelpittet’s picture

That's neat, the snippet doesn't need the hook? I'd check but I'm on a phone atm. Thanks for the fix.

prateekjain’s picture

Status: Needs review » Reviewed & tested by the community

Patch looks good. Changing it to RTBC

Jeff Burnz’s picture

Status: Reviewed & tested by the community » Needs review

looks good, but I note the test doesn't have the type declaration, should we update that also, is it required etc?

lhuria94’s picture

Yes the snippet doesn't need the hook, updating the patch with required parameter and documentation changes.

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Documentation

Thank you. That is a nice clear cleanup

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: incorrect-documentation-changed-param-2751923.patch, failed testing.

joelpittet’s picture

Status: Needs work » Reviewed & tested by the community

  • xjm committed 8e04ab6 on 8.2.x
    Issue #2751923 by mohit_aghera, lhuria94, Jeff Burnz, joelpittet:...

  • xjm committed 2144d10 on 8.1.x
    Issue #2751923 by mohit_aghera, lhuria94, Jeff Burnz, joelpittet:...
xjm’s picture

Status: Reviewed & tested by the community » Fixed

The 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!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.