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.
The "Reset the dependent to its default values when the form is submitted if the dependency is not triggered" option does not work.
Looking at the code, it is a remnant of D7
Comment | File | Size | Author |
---|---|---|---|
#19 | 2833343-19.patch | 7.39 KB | paulocs |
#19 | interdiff-16-19.txt | 1.12 KB | paulocs |
#17 | 2833343-16.patch | 7.53 KB | paulocs |
#14 | 2833343-14.patch | 8.71 KB | hmendes |
| |||
#14 | patch_error_2833343-14.png | 12.36 KB | hmendes |
Comments
Comment #2
zerolab CreditAttribution: zerolab at Torchbox for The Chartered Society of Physiotherapy commentedAttaching a patch that fixes the issue.
It does not yet cover the
CONDITIONAL_FIELDS_DEPENDENCY_VALUES_WIDGET
case fromconditional_fields_evaluate_dependency()
Comment #3
itsekhmistro CreditAttribution: itsekhmistro at Adyax commentedUpdated patch from #2 to match latest 8.x-1.x-dev version.
Comment #4
OlgaRabodzei CreditAttribution: OlgaRabodzei at Adyax commentedHello!
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.
Comment #5
zerolab CreditAttribution: zerolab at Torchbox for The Chartered Society of Physiotherapy commentedHere 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.Comment #6
marvil07 CreditAttribution: marvil07 at Isovera for Pegasystems commentedThe 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:
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.
Comment #7
marvil07 CreditAttribution: marvil07 at Isovera for Pegasystems commentedLooking 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.
Comment #8
colanCode looks fine, but patch doesn't apply.
Comment #9
olofbokedal CreditAttribution: olofbokedal at Odd Hill commentedRe-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.
Comment #10
paulocs@thalles, I did a new patch. Can you please have a look? It is not working properly.
Comment #11
paulocsI did a new patch for 8.x-1.x-dev. Please review it.
Thanks!
Comment #12
amykhailova CreditAttribution: amykhailova at Kalamuna commented#11 didn't work for me. But I re-rolled 11 with against 8.x-1.x-dev. Please test it out.
Comment #13
Kris77 CreditAttribution: Kris77 commentedThank you so much @amykhailova,
your patch in #12 works fine for me with beta10 and Drupal 9
Comment #14
hmendes CreditAttribution: hmendes at CI&T commentedHello!
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.
Comment #15
paulocsComment #16
paulocsComment #17
paulocsNew patch... I didn't attach an interdiff because #14 can't be applied.
Please review.
Comment #18
paulocsI 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.
Comment #19
paulocsA new patch...
Comment #20
hmendes CreditAttribution: hmendes at CI&T commentedHello!
Tested patch from #19 and it worked here. Changing to RTBC.
Tested with Drupal 9.1.9 and Conditional Fields 4.x-dev.
Comment #21
Kris77 CreditAttribution: Kris77 commentedPatch in #19 works for me too.
Thank you so much @paulocs
Comment #22
lexsoft CreditAttribution: lexsoft commentedThe #19 patch works for me. Thanks a lot for this :)
Comment #23
thallesLooks good to me!
Comment #25
thallesComment #27
tamarackmedia CreditAttribution: tamarackmedia commentedThis 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.
Comment #28
tamarackmedia CreditAttribution: tamarackmedia commentedI 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).