When I create a dependency on an entity reference field (taxonomy term) to have a specific term out of this vocabulary the following error shows up on the page. It appears everything is working as expected though.

Notice: Undefined offset: 0 in Drupal\conditional_fields\Plugin\conditional_fields\handler\EntityReference->statesHandler() (line 28 of /Users/sites/drupal/modules/contrib/conditional_fields/src/Plugin/conditional_fields/handler/EntityReference.php) #0 /Users/sites/drupal/core/includes/bootstrap.inc(566): _drupal_error_handler_real(8, 'Undefined offse...', '/Users/sites/dr...', 28, Array) #1 /Users/sites/drupal/modules/contrib/conditional_fields/src/Plugin/conditional_fields/handler/EntityReference.php(28): _drupal_error_handler(8, 'Undefined offse...', '/Users/sites/dr...', 28, Array) #2 /Users/sites/drupal/modules/contrib/conditional_fields/conditional_fields.api.inc(225): Drupal\conditional_fields\Plugin\conditional_fields\handler\EntityReference->statesHandler(Array, NULL, Array) #3 /Users/sites/drupal/modules/contrib/conditional_fields/conditional_fields.api.inc(85): conditional_fields_get_state(Object(Drupal\Core\Entity\Entity\EntityFormDisplay), 'field_term_ref', Array, Array) #4 [internal function]: conditional_fields_form_after_build(Array, Object(Drupal\Core\Form\FormState)) #5 /Users/sites/drupal/core/lib/Drupal/Core/Form/FormBuilder.php(1064): call_user_func_array('conditional_fie...', Array) #6 /Users/sites/drupal/core/lib/Drupal/Core/Form/FormBuilder.php(557): Drupal\Core\Form\FormBuilder->doBuildForm('node_article_ed...', Array, Object(Drupal\Core\Form\FormState)) #7 /Users/sites/drupal/core/lib/Drupal/Core/Form/FormBuilder.php(314): Drupal\Core\Form\FormBuilder->processForm('node_article_ed...', Array, Object(Drupal\Core\Form\FormState)) #8 /Users/sites/drupal/modules/contrib/conditional_fields/src/Form/ConditionalFieldEditForm.php(522): Drupal\Core\Form\FormBuilder->buildForm('node_article_ed...', Object(Drupal\Core\Form\FormState)) #9 /Users/sites/drupal/modules/contrib/conditional_fields/src/Form/ConditionalFieldEditForm.php(145): Drupal\conditional_fields\Form\ConditionalFieldEditForm->getDummyField('node', 'article', Array, Object(Drupal\Core\Form\FormState), Array) #10 [internal function]: Drupal\conditional_fields\Form\ConditionalFieldEditForm->buildForm(Array, Object(Drupal\Core\Form\FormState), 'node', 'article', 'field_addtocal', '95fc998d-08a0-4...') #11 /Users/sites/drupal/core/lib/Drupal/Core/Form/FormBuilder.php(514): call_user_func_array(Array, Array) #12 /Users/sites/drupal/core/lib/Drupal/Core/Form/FormBuilder.php(271): Drupal\Core\Form\FormBuilder->retrieveForm('conditional_fie...', Object(Drupal\Core\Form\FormState)) #13 /Users/sites/drupal/core/lib/Drupal/Core/Controller/FormController.php(74): Drupal\Core\Form\FormBuilder->buildForm('conditional_fie...', Object(Drupal\Core\Form\FormState)) #14 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) #15 /Users/sites/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) #16 /Users/sites/drupal/core/lib/Drupal/Core/Render/Renderer.php(576): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #17 /Users/sites/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) #18 /Users/sites/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) #19 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() #20 /Users/sites/drupal/vendor/symfony/http-kernel/HttpKernel.php(153): call_user_func_array(Object(Closure), Array) #21 /Users/sites/drupal/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) #22 /Users/sites/drupal/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #23 /Users/sites/drupal/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #24 /Users/sites/drupal/core/modules/page_cache/src/StackMiddleware/PageCache.php(99): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #25 /Users/sites/drupal/core/modules/page_cache/src/StackMiddleware/PageCache.php(78): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true) #26 /Users/sites/drupal/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #27 /Users/sites/drupal/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #28 /Users/sites/drupal/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #29 /Users/sites/drupal/core/lib/Drupal/Core/DrupalKernel.php(657): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) #30 /Users/sites/drupal/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) #31 {main}.

CommentFileSizeAuthor
#3 one_more_error_when-2921478-3.patch824 bytesgg24

Comments

gg24 created an issue. See original summary.

gg24’s picture

Version: 8.x-1.x-dev » 8.x-1.0-alpha2
gg24’s picture

StatusFileSize
new824 bytes

Attaching a patch to fix this issue.
Please review.

Thanks!

gg24’s picture

Status: Active » Needs review
gg24’s picture

Assigned: gg24 » Unassigned
guptahemant’s picture

hi @gg24

I have applied the patch and it solves the mentioned issue, the other issue in description is https://www.drupal.org/node/2908866,
Marking the issue as RTBC.

guptahemant’s picture

Status: Needs review » Reviewed & tested by the community
colan’s picture

Title: One more error when creating dependency on taxonomy term » Undefined offset in plugin handler EntityReference->statesHandler()

Fixing title.

  • colan committed 72f4e2b on 8.x-1.x authored by gg24
    Issue #2921478 by gg24: Ensure the value form is set before using it.
    
colan’s picture

Status: Reviewed & tested by the community » Fixed

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.