Problem/Motivation

After installing the module (version 2.0.4) and clearing the cache, the field does not appear in the list of fields when adding a new field.

Steps to reproduce

1. Install Module
2. Clear Cache
3. Add a field to a content type
4. "Display Mode" is not an option

Proposed resolution

The issue is in the field definition of the field type file. The category says "reference" when it should have a capital R.

Current:

/**
 * Plugin implementation of the 'entity_reference_display' field type. 
 *
 * @FieldType(
 *   id = "entity_reference_display",
 *   label = @Translation("Display mode"),
 *   description = @Translation("This field allows you to specify a display mode for entity reference field."),
 *   category = "reference",
 *   default_widget = "options_select",
 *   default_formatter = "list_default"
 * )
 */

Fix:

/**
 * Plugin implementation of the 'entity_reference_display' field type.
 *
 * @FieldType(
 *   id = "entity_reference_display",
 *   label = @Translation("Display mode"),
 *   description = @Translation("This field allows you to specify a display mode for entity reference field."),
 *   category = @Translation("Reference"),
 *   default_widget = "options_select",
 *   default_formatter = "list_default"
 * )
 */
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

arparker created an issue. See original summary.

arparker’s picture

Pushed a fix to the FieldType file. Working on my local. Ready to be tested.

arparker’s picture

Status: Active » Needs review
jgraca’s picture

I also faced this issue and the fix by changing
* category = "reference",
to
* category = "Reference",
worked.

Changing it to
* category = @Translation("Reference"),
I got the error:
Uncaught PHP Exception TypeError: "Cannot access offset of type Drupal\Core\StringTranslation\TranslatableMarkup in isset or empty" at web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php line 45

norman.lol’s picture

Version: 2.0.4 » 2.0.x-dev
Status: Needs review » Closed (works as designed)

The module works as designed. It's just that you find the field under the reference fields now, not in the first level. The project page might need to get updated, reflecting that.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.