- Issue created by @grimal
- 🇺🇸United States jrockowitz Brooklyn, NY
The attached webform replicates the issue.
It is unlikely that this can be fixed.
- 🇳🇴Norway joeboris_
Hi,
Sorry to revive this, but I've been trying to accomplish different variants of conditional logic with the "File" and "Document file" fields, with no success*.
Does comment #3 entail that all conditional logic operations for file fields do not - and will not - work? Or just the "when filled" trigger/value is used? Are there other triggers, such as "Value is" which can be used successfully?
Can these behaviours be accomplished somehow by custom code or in some other way?
Any clarification / help / tips&tricks much appreciated!
joeboris* Specifically, I need to show/hide fields and/or make fields required or read-only based on whether or not a file has been uploaded.
- 🇮🇹Italy grimal
The issue seems to be caused by the fact that the visibility condition linked to the file is incorrectly replaced with a cross-page condition.
WebformSubmissionConditionsValidator::getConditionTargetsVisibility() appears to extract the field name incorrectly in the case of files. As a result, it cannot find the element, marks it as not visible, and this triggers the replacement.
By fixing the field name extraction, the issue seems to resolve.
However, in the case where the file is deleted after being uploaded, the update event does not seem to be triggered to re-hide the dependent field.
Hi,
Here's a patch from 8 years ago which fixes this issue and worked Happily on Drupal 10.3.6
An old conversation about the same issue...
https://www.drupal.org/project/webform/issues/2860529#comment-11992764 →The patch
https://www.drupal.org/files/issues/conditional_required-2860529-7.patch →Then within webforms, you can "conditionally" check if a field with a file is empty or not, (didn't test with the similar filled option).
- 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
Did the change get rolled-back?
If you have a fix, please put it into a merge request.