Closed (fixed)
Project:
Conditional Fields
Version:
8.x-1.0-alpha6
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
28 Sep 2019 at 10:17 UTC
Updated:
1 Jul 2020 at 18:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
EmiliaC commentedSeems like the patch from https://www.drupal.org/project/conditional_fields/issues/2859667 could not be applied from alpha5 to alpha6 because it was missing the base file conditional_fields.api.inc which is now transformed into the class ConditionalFieldsFormHelper.
I re-applied to /src/ConditionalFieldsFormHelper.php the patch that cslevy provided.
Please review and advise if it ok.
Comment #3
EmiliaC commentedComment #4
visualnotion commentedThank you for the patch.
I have tried it and it shows the asterisk and the attributes on my select field are marked as "required", but I can still submit the form without a making a selection in that field.
It appears to look fine, but just doesn't validate.
Comment #5
super_romeo commentedComment #6
megha_kundar commentedI have applied patch #2 and found that validation for that form is working fine. But, I could not find the asterisk symbol in the target field when the controlled field is checked. I have solved this issue by this modifying below js file and not sure whether this is the correct way please review this patch.
Comment #7
megha_kundar commentedComment #8
kris77 commentedI don't know if it can help, but I noticed something.
I have my content type with two field: Field_1 is boolean and Field_2 is term reference with checkbox widget.
So, I have set as "required" Field_1 and Field_2 too. In "Manage Dependencies" I have set only one condition:
Now, when create my content, if Field_1 is set to OFF and click on SAVE the node is create without problem. If Field_1 is set to ON, Field_2 is visible and asterisk is show too. If click on SAVE the node is NOT create and error message appears.
So, it seems that it is not necessary to set the condition required in "Manage Dependencies"
Comment #9
Steven McCoy commentedThis is my first time contributing, so please be gentle ;)
I modified the patch from #7, mainly to also add / remove the "required" attribute on the field, instead of just adding the flag to the label.
While I was in there, I also simplified some repetition with the jQuery references and the use of $.each
Comment #11
Steven McCoy commentedI've created a patch that toggles the required state of the field, in addition to just updating the label.
Additionally it makes for slightly cleaner and more performant jQuery calls.
Comment #12
ultrabob commentedSteven McCoy, thanks for your efforts on this. I haven't reviewed with any depth, but can confirm that the required asterisks show up where they should, they also show up in an unusual place: the text formatting selection. In a normal form those don't get a required asterisk, but they do after applying that patch.
Comment #13
ultrabob commentedHere is a new version of #9 with an updated selector to avoid affecting formatting labels.
Comment #14
ultrabob commentedI'm a fairly new contributor too, and I'm having trouble understanding the output of those test fails. I'll try to dig in and figure it out on my own if time allows, but if anybody has some guidance on what specifically to look at, I'd be grateful. I see one test that the body field is visible failing, which shouldn't have anything to do with the change I made, or the patch I based mine on.
Main thing I don't understand is how #7 passed but mine and the previous one have errors that almost seem to be about how the test is written.
Update: I can only surmise that the test fails that have popped up since the last patch that passes all tests, are at least partially due to changes in the module code unrelated to these fixes, and the patch is working properly for me, so unless I hear back, I'll probably set this aside for now.
Comment #15
JvE commentedComment #16
super_romeo commentedI have multiple field (cardinality 3). And all 3 field inputs are required, but should be only first. E.g.
<input name="field_phone[0][value]" ...>I think my addition is a dirty way. I guess a better way to look at which field inputs are required from initial page load and change attributes only of those inputs.
Comment #17
sashken2 commentedPatch #15 works very good. Thanks!
Comment #18
paulocsPatch #15 looks good to me.
I didn't understand the problem from comment #16. Maybe @super_romeo can write the steps to reproduce.
Comment #19
kris77 commentedPatch #15 works fine for me too.
Thanks @JvE
Comment #20
thallesComment #22
thallesFixed in dev branch!
Thanks @all!
Comment #23
thallesComment #24
thallesComment #25
sashken2 commentedthalles, why you committed patch #16 but not #15?
Comment #26
thallesThanks @sashken2!