To reproduce:
Go to Basic custom block type fields management and try to add an entityreference field...

Notice: Undefined index: type in Drupal\Core\TypedData\TypedDataManager->create() (line 131 of core/lib/Drupal/Core/TypedData/TypedDataManager.php).
InvalidArgumentException: Invalid data type <em class="placeholder"></em> has been given. in Drupal\Core\TypedData\TypedDataFactory->createInstance() (line 44 of /var/www/d8/core/lib/Drupal/Core/TypedData/TypedDataFactory.php).

Somehow in the $definition passed in TypedDataManager::create() there are only the field settings:/

#5 1935974-before.png70.43 KBandymartha
#5 1935974-after.png49.62 KBandymartha
#4 1935974-test-only.patch2.41 KBamateescu
FAILED: [[SimpleTest]]: [MySQL] 52,545 pass(es), 1 fail(s), and 1 exception(s). View
#4 1935974.patch3.95 KBamateescu
PASSED: [[SimpleTest]]: [MySQL] 52,546 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more


ParisLiakos’s picture

blueminds’s picture

Assigned: Unassigned » blueminds
ParisLiakos’s picture

Priority: Normal » Major

This makes entity reference useless when all entities become NG

amateescu’s picture

Assigned: blueminds » amateescu
Status: Active » Needs review
3.95 KB
PASSED: [[SimpleTest]]: [MySQL] 52,546 pass(es). View
2.41 KB
FAILED: [[SimpleTest]]: [MySQL] 52,545 pass(es), 1 fail(s), and 1 exception(s). View

It seems that this issue was already fixed in #1818556-120: Convert nodes to the new Entity Field API. I've extracted the fix from there and added a temporary test.

andymartha’s picture

Status: Needs review » Reviewed & tested by the community
49.62 KB
70.43 KB

I can confirm that on a fresh installation of Drupal 8.x-dev on March 6th, the problem described (entity reference crashing) was valid (see screenshot).
After applying 1935974.patch found in #4 by amateescu, I was able to successfully save an entity reference field to a custom block. See screenshot.

ParisLiakos’s picture

I can confirm that the patch fixes it:) that was quick, thanks all!

webchick’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +SprintWeekend2013

My sincere hope is that nodes as entity NG is just around the corner, so this is an important fix to get put away sooner than later.

Committed and pushed to 8.x. Thanks!

ParisLiakos’s picture

Status: Fixed » Reviewed & tested by the community

this was never pushed

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Huh, that's weird. And now that nodes as Entity NG is committed, this no longer applies. :(

amateescu’s picture

Status: Needs work » Closed (duplicate)

That's because this fix was already included in the nodes conversion patch :)