- Issue created by @jvogt
- 🇺🇸United States jvogt Seattle, WA
I think it's due to this line being remove in commit 7ec4b704 (line 399 in src/ConditionalFieldsFormHelper.php), causing the dependentValidation to execute when saving conditions:
if (!isset($form['#conditional_fields'])) { return; }
If you add that back in just after the following, the error goes away and the conditional field rules work:
$inline_entity_form_parents = self::findInlineEntityFormParentsForElement($form, $element); if ($inline_entity_form_parents) { $form = NestedArray::getValue($form, $inline_entity_form_parents['element_parents']); }
I don't know if this is the correct solution as the removal may have been intentional in issue 2856720 ✨ Support for Inline Entity Form Fixed . However, I tested the fix with my initial conditions and the conditional fields inside an "Inline entity form - Simple" and it worked. I didn't test with "Inline entity form - Complex".
- 🇸🇰Slovakia coaston
+1 I have got the same issue.
I am not using Inline Entity Form and I do not have installed it.In my case I have used dependency to field "B" and then I reused this field in another content type . However it takes from some reason dependency and it is displayed in the second content type and also to field "B" however such field "B" is not reused in the second content type, just the field "A" has been reused.
When I want to update that dependency now in the first content type I am getting this issueBut this
if (!isset($form['#conditional_fields'])) {
return;
}Resolved the issue.
Please try to create a patch.
- Status changed to Needs review
8 months ago 12:42pm 24 August 2024 - Status changed to Needs work
about 2 months ago 8:09am 13 February 2025 - 🇬🇧United Kingdom malcomio
I had observed the same error when trying to add a second dependency:
1. Field 2 is required if field 1 has value X
2. Field 3 is visible if field 2 has value YThis is not quite the same scenario as the original description, but very similar.
After applying the patch, I got the following error:
TypeError: Drupal\conditional_fields\ConditionalFieldsFormHelper::addStateToGroup(): Argument #1 ($new_states) must be of type array, null given, called in /var/www/html/docroot/modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php on line 276 in Drupal\conditional_fields\ConditionalFieldsFormHelper->addStateToGroup() (line 478 of modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php). Drupal\conditional_fields\ConditionalFieldsFormHelper->processDependeeFields(Array, Array, Array, Array, '') (Line: 154) Drupal\conditional_fields\ConditionalFieldsFormHelper->processDependentFields() (Line: 108) Drupal\conditional_fields\ConditionalFieldsFormHelper->afterBuild(Array, Object) (Line: 184) conditional_fields_form_after_build(Array, Object) call_user_func_array('conditional_fields_form_after_build', Array) (Line: 1082) Drupal\Core\Form\FormBuilder->doBuildForm('node_document_edit_form', Array, Object) (Line: 579) Drupal\Core\Form\FormBuilder->processForm('node_document_edit_form', Array, Object) (Line: 326) Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 591) Drupal\conditional_fields\Form\ConditionalFieldEditForm->getDummyField('node', 'document', Array, Object, Array) (Line: 153) Drupal\conditional_fields\Form\ConditionalFieldEditForm->buildForm(Array, Object, 'node', 'document', 'field_lawful_basis', 'ade41c73-6578-4e92-ad0a-514a0cbc7d6d') call_user_func_array(Array, Array) (Line: 536) Drupal\Core\Form\FormBuilder->retrieveForm('conditional_field_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)