Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
My content type has 2 fields, one of which is conditional on the other. They are both required fields. The dependee field is using a select widget, the dependent field is using a text field widget. When I hit "Save" on the node add form with these two fields empty, I get the following error:
Warning: array_values() expects parameter 1 to be array, string given in array_values() (line 874 of <snip>/sites/all/modules/conditional_fields/conditional_fields.module).
Please let me know if any further info would be helpful in debugging.
Comments
Comment #1
JordanMagnuson CreditAttribution: JordanMagnuson commentedI'm also receiving this error in a similar use case.
Comment #2
JordanMagnuson CreditAttribution: JordanMagnuson commentedSo here's the problem code from conditional_fields_evaluate_dependency:
The issue is that $dependency_values is a string (at least in my case), when it should be an array. Does anyone know the proper way to go about fixing this?
In my case the $values array looks like this:
array(0 => array(tid = '598'));
And $dependency_values is a simple string:
598
Any help fixing this is much appreciated!
Comment #3
mordek CreditAttribution: mordek commentedQuick fix:
Change line from:
return array_values($dependency_values) == array_values($values);
To this:
return array_values((array)$dependency_values) == array_values($values);
But as I said... it`s only quick fix ;)
Comment #4
mordek CreditAttribution: mordek commentedRelated to this i think #1299854: Warning: array_values(): The argument should be an array (line 874 of conditional_fields.module)
Comment #5
Georgique CreditAttribution: Georgique commentedSubscribe
Comment #6
peterpoe CreditAttribution: peterpoe commentedThis was fixed back in april 2012 by this commit.