When editing a node type that has no options checked for Autotagger, this error occurs:

Warning: Invalid argument supplied for foreach() in Drupal\Core\Render\Element\Checkboxes::valueCallback() (line 100 of core/lib/Drupal/Core/Render/Element/Checkboxes.php).
Drupal\Core\Render\Element\Checkboxes::valueCallback(Array, , Object)
call_user_func_array(Array, Array) (Line: 1258)
Drupal\Core\Form\FormBuilder->handleInputElement('node_type_edit_form', Array, Object) (Line: 975)
Drupal\Core\Form\FormBuilder->doBuildForm('node_type_edit_form', Array, Object) (Line: 1045)
Drupal\Core\Form\FormBuilder->doBuildForm('node_type_edit_form', Array, Object) (Line: 1045)
Drupal\Core\Form\FormBuilder->doBuildForm('node_type_edit_form', Array, Object) (Line: 557)
Drupal\Core\Form\FormBuilder->processForm('node_type_edit_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('node_type_edit_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
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}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
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: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
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: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

It doesn't seem to be hurting anything as the module still works but needs to be fixed.

CommentFileSizeAuthor
#5 checkboxes_error_2884430_5.patch655 bytesbrooke_heaton

Comments

Michelle created an issue. See original summary.

VishalKumarSahu’s picture

This issue still persists.

kmani’s picture

I am also getting same error.

Warning: Invalid argument supplied for foreach() in Drupal\Core\Render\Element\Checkboxes::valueCallback() (line 100 of core/lib/Drupal/Core/Render/Element/Checkboxes.php).
Drupal\Core\Render\Element\Checkboxes::valueCallback(Array, , Object)
call_user_func_array(Array, Array) (Line: 1273)
Drupal\Core\Form\FormBuilder->handleInputElement('sharethis_settings', Array, Object) (Line: 990)
Drupal\Core\Form\FormBuilder->doBuildForm('sharethis_settings', Array, Object) (Line: 1060)
Drupal\Core\Form\FormBuilder->doBuildForm('sharethis_settings', Array, Object) (Line: 1060)
Drupal\Core\Form\FormBuilder->doBuildForm('sharethis_settings', Array, Object) (Line: 1060)
Drupal\Core\Form\FormBuilder->doBuildForm('sharethis_settings', Array, Object) (Line: 561)
Drupal\Core\Form\FormBuilder->processForm('sharethis_settings', Array, Object) (Line: 318)
Drupal\Core\Form\FormBuilder->buildForm('sharethis_settings', Object) (Line: 93)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
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: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 67)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->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: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 51)
Drupal\jsonapi\StackMiddleware\FormatSetter->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: 665)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Thanks,
--Mani

brooke_heaton’s picture

Assigned: Unassigned » brooke_heaton

This error is due to an empty value on $form['autotagger']['autotagger_source_field']['#options']. Setting this to an empty array if $default_source is not set should resolve this.

'#default_value' => ($default_source) ? $default_source : [],

brooke_heaton’s picture

StatusFileSize
new655 bytes

Patch add ternary to set #default_value to empty array if $default source returns empty.

brooke_heaton’s picture

Status: Active » Needs review
michelle’s picture

LOL! I just got this same error in something completely unrelated and remembered there was a patch in here for it and now I know how to fix my custom code. Now I owe you. :) I will try to get this patch committed during our contrib time tomorrow. :)

michelle’s picture

Status: Needs review » Fixed

Tested and confirmed it worked. Committed. Thanks for the patch!

brooke_heaton’s picture

Yass!

Status: Fixed » Closed (fixed)

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