- Issue created by @marksmith
- 🇺🇸United States josh.fabean
Can confirm I get the same exact error. That is strange, checking around integer is a valid base field definition that is used in Drupal Core.
Here is an example from core core/lib/Drupal/Core/Entity/ContentEntityBase.php
$fields[$entity_type->getKey('id')] = BaseFieldDefinition::create('integer') ->setLabel(new TranslatableMarkup('ID')) ->setReadOnly(TRUE) ->setSetting('unsigned', TRUE);
Here is how this module does it.
$fields['slots'] = BaseFieldDefinition::create('integer') ->setLabel(t('Slots')) ->setDescription(t("The number of available slots for this instance. If empty (NB not zero), will use calendar's defaults.")) ->setCardinality(1) ->setDisplayOptions('form', [ 'type' => 'integer', 'weight' => 10, ]) ->setSetting('min', 0) ->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('view', TRUE);
I see other drupal core issues that address having the same issue not sure I see a solution yet though. I'll look and see if I can find anything.
- 🇮🇪Ireland marksmith
Ok, now I see it. The problem is with this line of code:
->setDisplayOptions('form', [ 'type' => 'integer', 'weight' => 10, ])
which should be:
->setDisplayOptions('form', [ 'widget_type' => 'integer', 'weight' => 10, ])
This code change solves the problem in my case.
-
josh.fabean →
committed 214d8f3f on 2.2.x
Issue #3384065 by marksmith, josh.fabean: Unable to add entity reference...
-
josh.fabean →
committed 214d8f3f on 2.2.x
- Status changed to Fixed
over 1 year ago 6:14pm 29 August 2023 - 🇺🇸United States josh.fabean
Good find, got that fixed and pushed to new version 2.2.9.
Automatically closed - issue fixed for 2 weeks with no activity.