API page: https://api.drupal.org/api/drupal/core%21modules%21field%21field.api.php...
As seen in this comment as well https://api.drupal.org/comment/57233#comment-57233 (yes, I commented first, sorry) the code sample is wrong in the documentation.
The 'field types' key is actually 'field_types' so the correct code would be:
function hook_field_formatter_info_alter(array &$info) {
// Let a new field type re-use an existing formatter.
$info['text_default']['field_types'][] = 'my_field_type';
}
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | incorrect_doc-2354005-1.patch | 542 bytes | benelori |
Comments
Comment #1
benelori commentedSubmitted patch for this
Comment #2
benelori commentedComment #3
jhodgdonThanks! Yes, it was "field types" with a space in Drupal 7, but I agree it's been changed in Drupal 8, as you can see in telephone_field_formatter_info_alter() in Drupal 8. In Drupal 8 the hook alters collected annotation information, and in annotation the info is "field_types" without the space.
Committed to 8.0.x.