Download & Extend

Problem with "Reset the dependent to its default values if the dependency is not triggered."

Project:Conditional Fields
Version:7.x-3.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

I have a fresh install of Drupal 7 with a basic dependency created. The dependent and controlling fields are both term reference fields, using radio select buttons. My goal is to simply make the dependent field visible when "Option A" is selected in the controlling field (otherwise the dependent field is not shown).

This works fine.

However, I also want the value of the dependent field to resort back to the default (N/A - nothing selected) if the user "changes their mind" and selects something other than Option A in the controlling field. I should be able to accomplish this by selecting "Reset the dependent to its default values if the dependency is not triggered" under the "Node edit settings", I believe. However, when I select that option, I get the following error message:

An illegal choice has been detected. Please contact the site administrator.
Warning: array_values() expects parameter 1 to be array, string given in conditional_fields_evaluate_dependency() (line 874 of /srv/www/pixelscrapper/public_html/sites/all/modules/contrib/conditional_fields/conditional_fields.module).

Any help in resolving this is appreciated. Thanks for the great module!

Comments

#1

I just found this as well. I've got a patch.

AttachmentSize
reset_if_not_triggered.diff 744 bytes

#2

Status:active» needs review

Nice, thanks Ryan! Haven't done a lot of testing, but so far your patch seems to do the trick...

#3

Hm... so this was working okay for me in the case of two checkbox/radio fields, but now I have an integer text field that is dependent on a checkbox field (term reference), and when I uncheck the controlling field the integer field does not return to its default value... any ideas?

#4

Ah... I see in the documentation:

Reset the dependent to its default values if the dependency is not triggered.
Note: works only with Text and Options widgets. Enabling this options with other types of widgets could lead to unexpected results.

I suppose there's a particular reason that the other widgets are hard to implement with this functionality?

#5

Can anyone else verify this problem/fix? It would be great to get a fix rolled for this (especially if it's as simple as the submitted patch)...

#6

Patch works for me! Thanks

#7

I am having a problem, too, and it's either the same issue or closely related. I tried the patch and it didn't clear it up for me.

This screencast illustrates the issue I am having: The values being reverted back are the wrong ones. Looks like the last value in all those to be restored is the one that gets written into all of the fields.

http://dl.dropbox.com/u/4770698/Drupal-org/Conditional_Fields_Bug.mov

#8

I experienced this same warning message when I had two required fields that were both dependent fields. I was not getting the validation error I expected, but this warning was returned.

Making the change in #1 fixed it for me.

nobody click here