Problem/Motivation

Warning: Undefined array key "call" in Drupal\conditional_fields\Plugin\conditional_fields\handler\OptionsButtons->checkBoxesHandler() (line 188 of modules/contrib/conditional_fields/src/Plugin/conditional_fields/handler/OptionsButtons.php).
Drupal\conditional_fields\Plugin\conditional_fields\handler\OptionsButtons->checkBoxesHandler(Array, NULL, Array) (Line: 23)
Drupal\conditional_fields\Plugin\conditional_fields\handler\OptionsButtons->statesHandler(Array, NULL, Array) (Line: 263)
Drupal\conditional_fields\ConditionalFieldsFormHelper->getState('field_contact_type', Array, Array) (Line: 163)
Drupal\conditional_fields\ConditionalFieldsFormHelper->processDependeeFields(Array, Array, Array, Array) (Line: 111)
Drupal\conditional_fields\ConditionalFieldsFormHelper->processDependentFields() (Line: 85)
Drupal\conditional_fields\ConditionalFieldsFormHelper->afterBuild(Array, Object) (Line: 405)
conditional_fields_form_after_build(Array, Object)
call_user_func_array('conditional_fields_form_after_build', Array) (Line: 1079)
Drupal\Core\Form\FormBuilder->doBuildForm('node_rfq_edit_form', Array, Object) (Line: 575)
Drupal\Core\Form\FormBuilder->processForm('node_rfq_edit_form', Array, Object) (Line: 321)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 578)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 717)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

And next same error for whatsapp array key.

Steps to reproduce

  1. Create List (text) field field_contact_type with values call
    whatsapp and mail. Cardinality unlimited. Change the form display to Check boxes/radio buttons
  2. Create Telephone number field field_phone.
  3. Create dependency:
    Target field: field_phone.
    Controlled by: field_contact_type.

Comments

super_romeo created an issue. See original summary.

hmendes’s picture

Status: Active » Needs review
StatusFileSize
new657 bytes

Adding a patch to fix this problem.

marcos_lima’s picture

StatusFileSize
new735 bytes
new664 bytes

Thank you for the patch @hmendes! I reviewed it, going through the following steps:
1) Reproduced the warning
2) Applied the patch
3) Replicated the steps to reproduce.
The problem was still present. Then I did a code review of the changes, and I think that’s because the added IF statement was never true.
So I changed it to reflect the case in question (List (text) with checkboxes) and then it worked and the warning stopped appearing.
Attached is the patch with this change and the interdiff from the previous patch.

hmendes’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Thank @marcos_lima for fixing the patch,
I tested here and it worked when i follow the steps in the IS, but the problem is still happening when the field is a Taxonomy (also with unlimited cardinality and as checkboxes ).
The patch provided fixes the issue when the field is a list(text) cause it was trying to get the first checkbox, instead of all checkboxes, when I tested with the Taxonomy field, the problem is that the key of the checkbox is not the same of its value. IMO we should create another issue to fix the problem with Taxonomy field, and move this one to RTBC.

  • colan committed 4033018 on 4.x authored by hmendes
    Issue #3244630 by marcos_lima, hmendes, super_romeo: Warning: Undefined...
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.