Creating conditional field dependencies do not allow entities to be added

Created on 4 June 2025, 10 days ago

Problem/Motivation

I wanted to hide a custom field depending on the value of a select list.
This may be a conditional fields issue so we can move it there if we need to, but conditional fields does work with other paragraph fields.

After adding it and trying to add the parent paragraph I got an error:

TypeError: Drupal\conditional_fields\ConditionalFieldsFormHelper::elementAddProperty(): Argument #1 ($element) must be of type array, null given, called in /var/www/html/web/modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php on line 270 in Drupal\conditional_fields\ConditionalFieldsFormHelper->elementAddProperty() (line 1083 of /var/www/html/web/modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php).

#0 /var/www/html/web/modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php(270): Drupal\conditional_fields\ConditionalFieldsFormHelper->elementAddProperty()
#1 /var/www/html/web/modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php(154): Drupal\conditional_fields\ConditionalFieldsFormHelper->processDependeeFields()
#2 /var/www/html/web/modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php(108): Drupal\conditional_fields\ConditionalFieldsFormHelper->processDependentFields()
#3 /var/www/html/web/modules/contrib/conditional_fields/conditional_fields.module(184): Drupal\conditional_fields\ConditionalFieldsFormHelper->afterBuild()
#4 [internal function]: conditional_fields_form_after_build()
#5 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1082): call_user_func_array()
#6 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(449): Drupal\Core\Form\FormBuilder->doBuildForm()
#7 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(633): Drupal\Core\Form\FormBuilder->rebuildForm()
#8 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm()
#9 /var/www/html/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm()
#10 [internal function]: Drupal\Core\Controller\FormController->getContentResult()
#11 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#12 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#13 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#14 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#15 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#16 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#17 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#18 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#19 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#20 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(116): Drupal\Core\StackMiddleware\ContentLength->handle()
#21 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(90): Drupal\page_cache\StackMiddleware\PageCache->pass()
#22 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
#23 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#24 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#25 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#26 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#27 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#28 {main}

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

3.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States nicxvan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @nicxvan
  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    I think something is going on with the form because the field is not in the form array: https://git.drupalcode.org/project/conditional_fields/-/blob/4.x/src/Con...

    So it looks like it's trying to get PG_field_container -> widget -> 0 -> subform -> custom_field -> widget -> 0 -> text -> format -> guidelines

    guidelines does not exist, I have it hidden, maybe I can change that.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    Still not sure if this is conditional fields or custom field.

    I found out that if I hide the format guidelines and help text then conditional fields blows up one conditional fields.

  • πŸ‡ΊπŸ‡ΈUnited States apmsooner

    Can't reproduce and seems like a conditional fields issue. Reopen if you discover otherwise. I personally think conditional fields type functionality could be handled in custom field module anyway. I'm not very inclined to support integration with a contrib module that is in alpha status and hasn't had a release in 6 months. Even the dev version has not had any merged commits since last December. That module is clearly not maintained IMO. Create a feature request if you want for our own version of conditional fields.

  • πŸ‡ΊπŸ‡ΈUnited States nicxvan

    We can actually just move the issue to that queue. I'll track it there.

Production build 0.71.5 2024