Problem/Motivation

After upgrading this module from version 4.0.0-alpha5 to 4.0.0-alpha6, I encountered the following issues:


Warning

Warning: Trying to access array offset on value of type null in Drupal\conditional_fields\ConditionalFieldsFormHelper::formFieldGetValues() (line 900 of /var/www/html/public/modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php) #0 /var/www/html/public/core/includes/bootstrap.inc(166): _drupal_error_handler_real(2, 'Trying to acces...', '/var/www/html/p...', 900)
#1 /var/www/html/public/modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php(900): _drupal_error_handler(2, 'Trying to acces...', '/var/www/html/p...', 900)
#2 /var/www/html/public/modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php(830): Drupal\conditional_fields\ConditionalFieldsFormHelper::formFieldGetValues(NULL, Object(Drupal\Core\Form\FormState))
#3 [internal function]: Drupal\conditional_fields\ConditionalFieldsFormHelper::formValidate(Array, Object(Drupal\Core\Form\FormState))
#4 /var/www/html/public/core/lib/Drupal/Core/Form/FormValidator.php(82): call_user_func_array(Array, Array)
#5 /var/www/html/public/core/lib/Drupal/Core/Form/FormValidator.php(274): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState))
#6 /var/www/html/public/core/lib/Drupal/Core/Form/FormValidator.php(118): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'application_edi...')
#7 /var/www/html/public/core/lib/Drupal/Core/Form/FormBuilder.php(593): Drupal\Core\Form\FormValidator->validateForm('application_edi...', Array, Object(Drupal\Core\Form\FormState))
#8 /var/www/html/public/core/lib/Drupal/Core/Form/FormBuilder.php(326): Drupal\Core\Form\FormBuilder->processForm('application_edi...', Array, Object(Drupal\Core\Form\FormState))
...



Error

TypeError: Drupal\Component\Utility\NestedArray::getValue(): Argument #2 ($parents) must be of type array, null given, called in /var/www/html/public/modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php on line 905 in Drupal\Component\Utility\NestedArray::getValue() (line 69 of /var/www/html/public/core/lib/Drupal/Component/Utility/NestedArray.php).
"/var/www/html/public/modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php:905",
"/var/www/html/public/modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php:830",
"/var/www/html/public/core/lib/Drupal/Core/Form/FormValidator.php:82",
"/var/www/html/public/core/lib/Drupal/Core/Form/FormValidator.php:274",
"/var/www/html/public/core/lib/Drupal/Core/Form/FormValidator.php:118",
"/var/www/html/public/core/lib/Drupal/Core/Form/FormBuilder.php:593",
"/var/www/html/public/core/lib/Drupal/Core/Form/FormBuilder.php:326",
...

Steps to reproduce

  1. Install version 4.0.0-alpha5 of conditional_fields.
  2. Upgrade to version 4.0.0-alpha6.
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

franceslui created an issue. See original summary.

franceslui’s picture

Issue summary: View changes

nicxvan’s picture

Are you able to add a test for this?

franceslui’s picture

I am unable to allocate time to implement a test at the moment. I would greatly appreciate assistance with this, or I can revisit it when my schedule permits. Thank you for your understanding.

joelpittet’s picture

Version: 4.0.0-alpha6 » 4.x-dev
Status: Active » Needs review

Targetting against the dev branch instead of the specific version and changing to needs review.

Seems like a regression by accident presumably in #2902164: Controlled-by fields inside a Paragraph don't work
https://git.drupalcode.org/project/conditional_fields/-/commit/962c0a834...

Unfortunately the previous code that worked didn't document why it was needed, nor does the new code document why it's not, so kinda hard to write a test, no?

rnsrk made their first commit to this issue’s fork.

rnsrk’s picture

Status: Needs review » Reviewed & tested by the community

Works as expected.

jcandan’s picture

I can also confirm this fixes the error as seemingly introduced by #2902164: Controlled-by fields inside a Paragraph don't work.

odensc’s picture

+1 - tested and works on our site with complex nested logic + inline entity forms. This fixes the weird regression I described in #2902164-232: Controlled-by fields inside a Paragraph don't work.

nicxvan’s picture

Test only fails as expected, thanks for the test case!

I also reviewed this and it looks good too.

leducdubleuet’s picture

Would it be possible please to have a new release including this fix?

Thank you!

dhaval_panara’s picture

Due to recent updates in the patch https://git.drupalcode.org/project/conditional_fields/-/merge_requests/6... is getting failed to apply on "drupal/conditional_fields": "4.x-dev@dev" version.

dhaval_panara’s picture

Patch is working till "Merge branch conditional_fields:4.x into 3495402-warning-trying-to" - 42d4ae5ebea9cd077930e6a6cce290edac608822.

URL of the patch : https://git.drupalcode.org/project/conditional_fields/-/commit/047da7b69...

However, it's not working after "fix phpcs issues" commit and with it's hash.

dhaval_panara’s picture

Patch is working fine after upgrading to the latest dev version.

joelpittet changed the visibility of the branch 4.x to hidden.

joelpittet’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 4.x

@franceslui for the report and the fix itself, @rnsrk for the test coverage, @nicxvan for pushing for a test case, and @jcandan and @odensc for confirming it on real sites. This one had been throwing WSODs for people (I see 9 followers) with nested conditional setups since alpha6, so it's good to have it closed out. 🎉

AI disclosure: While doing the MR conflicts most from 40017ea, used AI to to cut the MR back to what 4.x didn't already cover, and to rewrite the unit test to assert behaviour against a real FormState rather than a mock(my preference). I reviewed the result and verified it with a red (tests-only)/green (tests + fixes). Also, I have been using this patch for ages (scratching an itch)!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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