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

JordanMagnuson’s picture

I'm also receiving this error in a similar use case.

JordanMagnuson’s picture

Title: Error on submitting form with conditional, required fields not given values » Problem with $dependency_values in conditional_fields_evaluate_dependency

So here's the problem code from conditional_fields_evaluate_dependency:

    // If we are in form context, we are done here.
    if ($context == 'edit') {
      // Compare arrays recursively ignoring keys, since multiple select widgets
      // values have numeric keys in form format and string keys in storage
      // format.
      return array_values($dependency_values) == array_values($values);
    }

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!

mordek’s picture

Quick 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 ;)

mordek’s picture

Georgique’s picture

Subscribe

peterpoe’s picture

Status: Active » Fixed

This was fixed back in april 2012 by this commit.

Status: Fixed » Closed (fixed)

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