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.
When the dependent is set up to be required when the dependee is triggered, then the JS is added correctly the user will see the red star, but when saving the node the module does not check if the field that is required is filled or not.
However it would be nice if drupal enforced this required state.
Comment | File | Size | Author |
---|---|---|---|
#1 | handle-required-on-form-submission-2180107-1.patch | 1.33 KB | nagy.balint |
Comments
Comment #1
nagy.balint CreditAttribution: nagy.balint commentedI created a patch that adds this functionality in the element's validate hook.
It most likely can be improved but this version works for me now.
Comment #2
cdracars CreditAttribution: cdracars commentedTested patch and seems to work fine.
Comment #3
jacktiong92 CreditAttribution: jacktiong92 commentedHi guys! I've installed Conditional Fields 7.x-3.0-alpha1 module and I need some help here. I am using Node Registration module and I've setup a form through node registration module and merge it together with the conditional fields module. In my form, the registrant is required to check certain checkboxes and extra fields (that needs validation) will appeared. However, I am facing the same problem as nagy.balint because even if the registrant submits the form without filling the necessary fields after the checkbox has been checked, the form will still be submitted. I have also tried to applied this patch but it is still not working. Please help me sir! Thanks in advance!
Comment #4
Outi CreditAttribution: Outi commentedHi, I've tried this patch, too, and it's not working for me.
I have a simple text field (TF1) with another text field as dependent (TF2). When the TF1 is empty, the TF2 is hidden. When the TF1 is filled, the TF2 is showed and required. There is the little star next to it but I can anyway save the form without filling the TF2.
Do you nagy.balint or does someone else have any idea of what could be wrong ?
Comment #5
Outi CreditAttribution: Outi commentedActually the patch seems to work when the debendee is set to have a value. In my case that's ok! With other conditions it doesn't seem to work.
Comment #6
System Lord CreditAttribution: System Lord commentedThis patch seems to be working. Thank you!
Comment #7
elpino CreditAttribution: elpino commentedThis patch worked for condition 'when dependee has value...'.
Other conditions would have to be tested or implemented.
Comment #8
Croga CreditAttribution: Croga commentedNo luck. I'm using "when dependee has value..." and the patch did not solve the problem.
Comment #9
System Lord CreditAttribution: System Lord commentedReceive this list of notices when setting up new fields and dependencies. They're lines from this patch.
•Notice: Undefined index: #entity_type in conditional_fields_dependent_validate() (line 675 of /home/site/public_html/sites/all/modules/conditional_fields/conditional_fields.module).
•Notice: Undefined index: #bundle in conditional_fields_dependent_validate() (line 675 of /home/site/public_html/sites/all/modules/conditional_fields/conditional_fields.module).
•Notice: Undefined index: dependents in conditional_fields_dependent_validate() (line 676 of /home/site/public_html/sites/all/modules/conditional_fields/conditional_fields.module).
•Warning: Invalid argument supplied for foreach() in conditional_fields_dependent_validate() (line 677 of /home/site/public_html/sites/all/modules/conditional_fields/conditional_fields.module).
The dependency is: "visible" when x is selected. Not setting "Required" at all. The only thing I've done different than usual is I'm using this on term reference field with the "Autocomplete term widget (tagging)" widget (as the Dependent). Maybe that has something to do with the errors? The dependee is the usual term reference - select list.
Update: switched from "autocomplete" to "select list" and still same notices/warning. I'm using CF a lot on my site and don't see any errors with them. Could my vocabulary be corrupt?
Update: created new vocabulary. Still same notices/warning. So, I have two fields/vocabularies. One with all 50 states names/terms (dependee) and the other with all Ohio city names/terms (dependent). When I select any state other than Ohio (dependent hidden) then "save" I get no errors. Only when I select Ohio and save do I get these errors.
Update: Installed 7.30 and these errors don't appear. However, not having this patch takes me back to the topic of the thread.
Comment #10
NWOM CreditAttribution: NWOM commentedThis appears to be a duplicate of #1561272: Conditionally required fields are not required.