Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zerolab created an issue. See original summary.

zerolab’s picture

Status: Active » Needs review
FileSize
3.74 KB

Attaching a patch that fixes the issue.

It does not yet cover the CONDITIONAL_FIELDS_DEPENDENCY_VALUES_WIDGET case from conditional_fields_evaluate_dependency()

itsekhmistro’s picture

Updated patch from #2 to match latest 8.x-1.x-dev version.

OlgaRabodzei’s picture

Status: Needs review » Closed (won't fix)

Hello!

Unfortunately this patches were outdated at all. And this functionality was removed from apha1 version, sorry. Probably we will add it again in future. If You really need it, You can create a new task for it and in addition provide a new patch.

Regards Olga.

zerolab’s picture

Status: Closed (won't fix) » Needs review
FileSize
6.03 KB

Here is an updated patch agains latest alpha.
We have a real use case on our project where we don't want user retain old values for the fields with unmet dependencies.

The patch cleans up conditional_fields_form_validate() which had a bunch of D7 code.

marvil07’s picture

Status: Needs review » Closed (cannot reproduce)

The current code, at 8.x-1.0-alpha5-1-gb855e9d, seems to be doing what the patch was intending to do.

Here it is what I tried:

  • Use a couple of fields, (a) a List (integer) with 3 values(1, 2, 3) as the control field, and (b) a text field as the target field.
  • dependency configuration: "The target field is visible when the control field has value...", setting the value to 2
  • Add an entity e1 with (a) set to 1, (b) is not visible, and not set as expected
  • Edit e1, set (a) to 2, (b) is now visible, add a value, and save; then both fields are set.
  • Edit e1, set (a) to 3, (b) is now not visible, and save; then (a) has a value, but (b) does not have the value set on the previous step.

Using the patch I get similar results.

It seems like the patch is not really needed, and the current default behavior is to reset the not visible fields.

Tentatively closing as I could not reproduce the problem.
Please re-open if needed, suggesting how to reproduce the problem.

marvil07’s picture

Title: Reset to default values doesn't work » Re-add reset to default values option
Status: Closed (cannot reproduce) » Reviewed & tested by the community

Looking this a bit more, it seems like the intention of the patch is not about removing the value of the dependent fields, but instead set the dependent field
default value when not visible.

With the patch used, I see the behavior change, and now the default value is set when the dependent field is not visible.
Hence, marking as RTBC now.

colan’s picture

Status: Reviewed & tested by the community » Needs work

Code looks fine, but patch doesn't apply.

olofbokedal’s picture

Re-rolled against alpha-6, since I need this in a current project.

The part with "Apply reset dependent to default if untriggered behavior" needs to be adjusted for the latest dev version, but it seems quite easy to relocate it.

paulocs’s picture

@thalles, I did a new patch. Can you please have a look? It is not working properly.

paulocs’s picture

I did a new patch for 8.x-1.x-dev. Please review it.
Thanks!

amykhailova’s picture

#11 didn't work for me. But I re-rolled 11 with against 8.x-1.x-dev. Please test it out.

Kris77’s picture

Thank you so much @amykhailova,

your patch in #12 works fine for me with beta10 and Drupal 9

hmendes’s picture

Status: Needs review » Needs work
FileSize
12.36 KB
8.71 KB

Hello!
Patch from #12 doesn't apply ( showing in the image ). Uploading the fixed patch.
The patch is working but I found a problem here: is not being possible to deselect the 'reset' checkbox when editing the conditional field ( when I deselect and save the condition, it is not being saved accordingly).
Tested on Drupal 9.1.6 and Conditional Field 8.x-1.x-dev.

paulocs’s picture

Version: 8.x-1.x-dev » 4.x-dev
paulocs’s picture

Assigned: Unassigned » paulocs
paulocs’s picture

Assigned: paulocs » Unassigned
Status: Needs work » Needs review
FileSize
7.53 KB

New patch... I didn't attach an interdiff because #14 can't be applied.
Please review.

paulocs’s picture

Assigned: Unassigned » paulocs
Status: Needs review » Needs work

I have to do a small modification because of if (in_array($key, $exclude_fields) || empty($value))
That is why we can't unchecked the checkbox in the ConditionalFieldEditForm.php.

paulocs’s picture

Assigned: paulocs » Unassigned
Status: Needs work » Needs review
FileSize
1.12 KB
7.39 KB

A new patch...

hmendes’s picture

Status: Needs review » Reviewed & tested by the community

Hello!
Tested patch from #19 and it worked here. Changing to RTBC.

Tested with Drupal 9.1.9 and Conditional Fields 4.x-dev.

Kris77’s picture

Patch in #19 works for me too.

Thank you so much @paulocs

lexsoft’s picture

The #19 patch works for me. Thanks a lot for this :)

thalles’s picture

Looks good to me!

  • paulocs authored 1afd174 on 4.x
    Issue #2833343 by paulocs, zerolab, hmendes, itsekhmistro, olofbokedal,...
thalles’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

tamarackmedia’s picture

This fix had worked for me in D8. After upgrading to D9 (specifically 9.2.9), the dependent values are ALWAYS getting reset, even when the dependency is still triggered. Switching back to the 4.0.0-alpha1 release for now, but hoping this gets fixed as the ability to reset has always been an important feature of this module.

tamarackmedia’s picture

I was able to resolve my issue from #27. I figured out the problem was limited to checkbox fields, and reset behavior works as expected when I change the condition from "Checked" to "Value", using the manual entry of values (the widget entry fails).