Problem/Motivation
We are encountering the following error when configuring a Field from Registration Type to the Widget from Module "readonly_field_widget".
Drupal\Core\Database\InvalidQueryException: Query condition 'registration_settings_field_data.entity_id IN ()' cannot be empty. in Drupal\Core\Database\Query\Condition->condition() (line 108 of core/lib/Drupal/Core/Database/Query/Condition.php).
Drupal\Core\Database\Query\Select->condition('registration_settings_field_data.entity_id', Array, 'IN') (Line: 77)
Drupal\Core\Entity\Query\Sql\Condition->compile(Object) (Line: 177)
Drupal\Core\Entity\Query\Sql\Query->compile() (Line: 82)
Drupal\Core\Entity\Query\Sql\Query->execute() (Line: 614)
Drupal\Core\Entity\EntityStorageBase->loadByProperties(Array) (Line: 56)
Drupal\registration\RegistrationSettingsStorage->loadSettingsForHostEntity(Object) (Line: 617)
Drupal\registration\HostEntity->getSettings() (Line: 315)
Drupal\registration\HostEntity->getCacheContexts() (Line: 171)
Drupal\Core\Cache\CacheableMetadata::createFromObject(Object) (Line: 54)
Drupal\registration\Plugin\Field\FieldFormatter\RegistrationTypeFormatter->viewElements(Object, 'de') (Line: 91)
Drupal\Core\Field\FormatterBase->view(Object, 'de') (Line: 268)
Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 226)
Drupal\Core\Entity\Entity\EntityViewDisplay->build(Object) (Line: 461)
Drupal\Core\Entity\EntityViewBuilder->viewField(Object, Array) (Line: 120)
Drupal\readonly_field_widget\Plugin\Field\FieldWidget\ReadonlyFieldWidget->formElement(Object, 0, Array, Array, Object) (Line: 459)
Drupal\Core\Field\WidgetBase->formSingleElement(Object, 0, Array, Array, Object) (Line: 85)
Drupal\readonly_field_widget\Plugin\Field\FieldWidget\ReadonlyFieldWidget->formMultipleElements(Object, Array, Object) (Line: 120)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 287)
Drupal\Core\Field\FieldItemList->defaultValuesForm(Array, Object) (Line: 35)
Drupal\registration\Plugin\Field\RegistrationItemFieldItemList->defaultValuesForm(Array, Object) (Line: 230)
Drupal\field_ui\Form\FieldConfigEditForm->form(Array, Object) (Line: 107)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('field_config_edit_form', Object) (Line: 284)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 741)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
We already debugged this and the "HostEntityInterface" in "RegistrationSettingsStorage::loadSettingsForHostEntity" has no ID.
Steps to reproduce
- Install Module readonly_field_widget
- Create some Node Bundle with a Registration field type.
- Configure this field to use the "ReadonlyFieldWidget" unter "...../form-display".
- Naviate back to "...../fields" and klick on "Edit" for the field.
Issue fork registration-3516694
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
Comment #2
john.oltman commentedComment #5
john.oltman commentedComment #6
john.oltman commentedThanks for posting this issue @daniel, I committed the fix to dev branch and it will be in the next release around May 4. You will need to first assign a default value to the field using the standard widget (i.e. assign a Registration Type to the field). After saving the default value, you can switch to using the read only widget, and you should select Registration Type as the formatter for the read only widget settings. If you don't do it this way, the registration field is essentially hidden on the node form, which defeats the purpose of using the read only widget vs just disabling the field on the form.