Download & Extend

Rename hook_elements() to hook_element_info()

Project:Drupal core
Version:7.x-dev
Component:base system
Category:task
Priority:normal
Assigned:sun
Status:closed (fixed)
Issue tags:DrupalWTF, Needs Documentation, Novice

Issue Summary

We introduced hook_element_info_alter() in #527804: element_info() cannot be altered, which now is kinda detached, because there is no hook_element_info(), but hook_elements() instead.

Simple change. Just grep + replace all instances of '_elements' with '_element_info' throughout core + change the hook invocation in element_info(), common.inc.

Comments

#1

Status:active» reviewed & tested by the community

Pretty much RTBC.

AttachmentSizeStatusTest resultOperations
drupal-element-info.patch14.89 KBIdleFailed: Failed to install HEAD.View details

#2

Status:reviewed & tested by the community» needs review

oopsie

#3

Status:needs review» needs work

The last submitted patch failed testing.

#4

Status:needs work» needs review

Makes sense, and should be good to go if bot comes back green.

My only nitpick is that the variable name $type looks odd in:

function text_element_info() {
  $type['text_textfield'] = array(
    '#input' => TRUE,   
    // ..
  );
  $type['text_textarea'] = array(
    '#input' => TRUE,
    // ..
  );
  $type['text_textarea_with_summary'] = array(
    '#input' => TRUE,
    // ..
  );
  return $type;
}

Why not $elements ? or $types (plural) ? or simply $return ?

#5

We use $type everywhere related to element types currently. So all of the contained changes are for consistency only. Renaming $type to $types or $elements might make sense, but I'd prefer to defer to a separate issue ;)

Failed to install HEAD doesn't sound nice... HEAD broken? :/

#6

"We use $type everywhere related to element types currently".
I'm fine with that, but the returned array should be named $types (plural), then ?

#7

What a stupid mistake... ;)

AttachmentSizeStatusTest resultOperations
drupal-element-info.6.patch15.24 KBIdlePassed: 12851 passes, 0 fails, 0 exceptionsView details

#8

ok, but only because it's you :)

Renamed everything to $types.

AttachmentSizeStatusTest resultOperations
drupal-element-info.8.patch21.44 KBIdlePassed: 12880 passes, 0 fails, 0 exceptionsView details

#9

Status:needs review» fixed

Committed to CVS HEAD. Thanks!

#10

Status:fixed» needs work
Issue tags:+Needs Documentation

Needs docs.

#11

Status:needs work» needs review

Added to update page.

#12

Status:needs review» fixed

Awesome!

#13

Status:fixed» closed (fixed)

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

nobody click here