Postponed (maintainer needs more info)
Project:
Conditional Fields
Version:
4.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Aug 2020 at 12:03 UTC
Updated:
6 Mar 2024 at 13:17 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
er.garg.karanFixed this issue by cherry picking code from https://www.drupal.org/files/issues/2019-10-04/3084387_required_behavior...
Comment #3
er.garg.karanAdded empty patch file by mistake. This is the one which worked for me.
Comment #4
guicom commentedThank you er.garg.karan, your patch work like a charm for me !!
Comment #5
alfattal commentedPatch in #3 worked for me only after applying a core patch from this issue. However, it's throwing this undefined index error
Notice: Undefined index: #entity_type in Drupal\conditional_fields\ConditionalFieldsFormHelper::dependentValidate() (line 358 of modules/contrib/conditional_fields/src/ConditionalFieldsFormHelper.php).Comment #6
sim_1Updating the target version. This patch works but it needs to be rerolled.
Comment #8
sim_1Ok after rerolling and testing @er.garg.karan's patch it worked great for me and automated tests passed as well. I didn't see the same warning @alfattal noticed. Marking RTBC.
Comment #9
peoriadrupaluser commentedHi, unfortunately this patch is not working for me as I would expect it to. I have installed 4.0.0-alpha2 and this patch using composer. I have verified that the code for the patch is in the source for my site.
I am trying to setup a set of conditions where if a checkbox is unchecked the dependent field (a date field) is required. When the checkbox is checked the dependent field should be optional and hidden. The second condition of hiding the date. The first condition to make the field required is not working.
I have tested that the required field is not working by trying to save a node without the date field and finding that it is not on the list of required fields that do not have values.
I am not seeing why this is not working for me so any suggestions are greatly appreciated.
Thanks,
Josh
Comment #10
aitala commentedThe patch did not work for me either -
I have a set of four checkboxes that are supposed to control if a link field (url and text) need to be filled out. The four conditions are all 'OR'd together... With all the boxes unchecked, all the link widgets are visible. When I start checking boxes the results are unpredictable.
What did work was changing the controlling field from checkboxes to a pulldown.
Thx
Eric
Comment #11
sim_1I'm having the same issue. It was working for me before. Now with alpha2 and drupal 9.5 it is no longer working.
Comment #12
saurabh-2k17 commentedHi, I am facing the same issue and came across this thread. I see there is also a dependency by Drupal core
I applied #3 patch from here along with other patch from the Drupal core issue, but this is not working.
Furthermore, I am also on Drupal core 9.5 and alpha2 version of module. I am curious to know what was the last Drupal core version for which this was working?
Comment #13
saurabh-2k17 commentedI am attaching a working patch here.
Comment #14
saurabh-2k17 commentedApologies for the wrong naming
Comment #15
saurabh-2k17 commentedComment #16
jmester13 commented@saurabh-2j17 I've tried your patch and the core patch and am not seeing a solution, but maybe because my setup is slightly different.
I have a required radio button.
When an option is selected, A required textbox should display.
When the option is not selected, the required textbox is hidden but does not allow the form to be submitted.
Also seeing this same behave for a checkbox which when selected should show a required address field.
Still researching and trying to find a solution but wanted to post here and follow.
Thanks!
Comment #17
jmester13 commentedAlrighty so update here for anyone else who runs into this issue I hope it helps.
I did not use these patches in the end it comes down to logic.
Do not set required on the field itself. Use the conditional logic to set required!
For example
(checkbox) Yes / No
Do you like Pizza?
If Yes, Show text field
If Yes, Make text field required.
For Address fields, I'm still working on a resolution, looking like some type of custom JS.
Comment #18
shani mauryaPatch in #3 worked for me only. Thank You!
Comment #19
problue solutionsOn Drupal 10.2 with Claro or Gin themes, when the checkbox is first clicked nothing happens, when it is clicked a second time the dependent field appears, and with each subsequent click the field disappears and appears correctly. It is only the very first click that does not work.
If Slide down effect is selected, on the first click it slides down but then immediately disappears again.
Patch #3 and #14 make no difference.
Comment #20
dqdThanks for the report and the efforts in here +1
Removed tag. Before adding tags read the issue tag guidelines. Do NOT use tags for adding random keywords or duplicating any other fields.
At the moment maintainers cannot reproduce this issue, tested with default Drupal 10.2 core and Claro setup (watch screen-cast). Please provide more reports and a screen-cast showing setup, themes and modules installed, so that we can make sure that this is really caused by CF.
Note: It makes a difference if the image field was set as required by default or not before, or if the checkbox has been checked already before or not for testing. To be able to turn off the required mode is already an issue because this is not working at the moment for good reasons. Therefor please follow: #3344587: Support for field hidden by condition losing its required status. In this issue you can find a trace back to another issue with a commit which has caused the momentary behavior of CF to not disable required mode.