Buy Now
Sign in

how to get disabled validation on conditionnal field

flodariege , December 02 2018
flodariege 48
December 02 2018 #381955
I am trying to get a checkboxes field being validated only if a specific option is selected inside another checkboxes group.
I tried many ways, but cannot get what I want. Maybe I don't do it the right way.
Here we go:
checkboxes 1 = choose one or several category
checkboxes 2 = choose one or several item inside the category chosen in checkboxes 1
This is the checkboxes_1 output in front:
When clicking an option, it opens a second (possibly a 3rd, 4th...) checkboxes, like this :
What I want, is preventing people not to make a choice inside the second list of options.
At this point, or I get validation while the 2nd list is hidden, or I don't get validation at all...
Let's have a look on backoffice :
Regarding the first checkboxes (category):
The validation tab (woking fine):
and the events (hiding/showing works fine, but not the enable/disable validation):
Let's now have a look at the 2nd checkboxes, the one I don't want to validate if it is hidden and disabled.
First, the validation tab:
And now the Info tab:
On the setup, I put a validate data action, but I think it is only checking for the consent checkbox prior the submit button (which validation works perfectly):
What am I doing wrong?
Even if I don't click the "chauffage" category, so the "solutions de chauffage" checkboxes stay hidden, CF6 validates it... and so it rejects the submit action.
I tried other settings, but then when the 2nd checkboxes are not hidden, and I don't chose nothing, the validation let it pass without saying nothing...
If only someone could tell me how to perform this... I've been trying for hours...
Thank you for your help
healyhatman 5.2
December 02 2018 #381961
You will need to either do the validation in PHP or have a series of event switcher actions. Data source for the switcher will be {data:checkbox1} or whatever, and in each of the options have a validate data action to validate only the fields that should be validated if that checkbox was ticked.
I would just do PHP validation in your case.
Also if they're not supposed to select an option, you should also disable it not just hide it.
Web developer at
I don't work for ChronoEngine but I do accept donations

You can now copy+paste code from forums
flodariege 48
December 02 2018 #381963
Hi healyhatman,
Thank you for your response.
I don't feel confident about the php validation (I don't even know where to start), but I guess I could find a logical way to get through this with the Event switcher action. I had no idea what it was for.
And I won't forget to disable and hide, not only hide.
Thank you.
I will probably come back here with questions (or maybe to tell you I succeed )
healyhatman 5.2
December 02 2018 #381964
Sure thing.
Just remember in those events, the "disable validation" is ONLY for the jquery validation on the front end and doesn't affect the back end, otherwise users would be able to just edit the code on the front end and bypass all your server validation.
Web developer at
I don't work for ChronoEngine but I do accept donations

You can now copy+paste code from forums
flodariege 48
December 07 2018 #382054
Hello healyhatman!
I'm sorry to bother you again, but I gave a try, and another, and another, and... but no way, I can't get how to set up the event switcher and validation correctly.
I also tried to find a good explanation inside the forum / faq / manual, with no success.
May I tell you what I did, so you could tell me what I did wrong and/or tell me what I am supposed to put as params?
Here we go:
On the design tab:
NAME: categorie_travaux

  • ID: categorie_travaux
    iso=Isolation thermique
    vmc=Ventilation (VMC)
    Required is ON
    Minimum choices: 1
    On Selecting chauffage => Enable + Show + Enable validation : solutions_chauffage
    On Unselecting chauffage => Disable + Hide + Disable validation : solutions_chauffage
  • Checkboxes:
    NAME: solutions_chauffage
    ID: solutions_chauffage
    12344=Pompe à chaleur air-eau
    12023=Climatisation réversible
    12434=Chaudière à granulés
    (and so on)
    Required is ON
    Minimum choices: 1
    Disabled is ON
    Error message: blablabla
    Validation rules : (nothing)
    Hidden: 1
    Disabled : (nothing)
    On the setup tab:
    On load:
    Display section
    On submit:
    Event switcher
    DATA PROVIDER: {data:categorie_travaux} (am I supposed to use the name or the ID? ie with or without the []?)
    chauffage,pv,ecs,iso,vmc (So I get 5 different events. let's have a look to the 1rst of them: )
    List errors: Yes
    Data provider: {data:solutions_chauffage} (again, should I use the square brackets? name or ID?)
    Fields list selection: All fields with validation rules
    On success:
    On fail:
    Event loader (with default values)
    Result: the 2nd checkboxes group show and hide, but if I don't tick anything in it while i selected chauffage in the 1rst checkboxes group, the form validates without any warning...
    There are so many different things I could have done wrong that I could spend a whole week trying to find the good combination...
    I feel almost desperate.
    Any little help would be very welcome.
    Thank you.
    healyhatman 5.2
    December 07 2018 #382055
    Data source should be the "name" of the field.
    And you shouldn't use all fields with validation rules you should manually put in the rules that should be valid for the selections you've made. Unless of course all rules is valid for that selection.
    Web developer at
    I don't work for ChronoEngine but I do accept donations

    You can now copy+paste code from forums
    flodariege 48
    December 07 2018 #382057
    I must be stupid, I don't understand.
    I used the name = solutions_chauffage [ ] } (with no space but if I put it here with no space it turns into a dot)
    {data:solutions_chauffage [ ] } (no space)
    Fields list selection: Only the fields entered below
    ...doesn't work.
    You takled about putting the rules, but I don't understand where to put those rules (I see a 'fields' case, not any 'Rules' case).
    And it says : ""Multiline list of fields to be included or excluded based on the setting above.
    I also tried a VALIDATE DATA rather than a VALIDATE FIELDS, putting this validation rules inside the field 'on the Design tab):

    solutions_chauffage [ ] /minChecked[1]:Merci de sélectionner au moins une Solution
    ... with no more success.