Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
I have the following code:
Code: Select all
<li class="clearfix checkbox">
    <p>I certify the following: </p>
    <cms:input type='checkbox' name='certify' id='certify' required='1' opt_values="ged=GED | othertext=schoolyear | sometext=curriculum  | text=records" />
    <cms:if k_error_certify>
        <p class="error">You must check all boxes to qualify for the 3rd option.</p>
    </cms:if>
</li>


It only throws an error if NONE of the checkboxes are checked. Is there any way to make it throw an error unless ALL of them are checked?

Thanks!
Mako88 wrote: I have the following code:
Code: Select all
<li class="clearfix checkbox">
    <p>I certify the following: </p>
    <cms:input type='checkbox' name='certify' id='certify' required='1' opt_values="ged=GED | othertext=schoolyear | sometext=curriculum  | text=records" />
    <cms:if k_error_certify>
        <p class="error">You must check all boxes to qualify for the 3rd option.</p>
    </cms:if>
</li>


It only throws an error if NONE of the checkboxes are checked. Is there any way to make it throw an error unless ALL of them are checked?

Thanks!


It is possible only on form submit, while in k_success. Remove 'required' from the input itself. In k_success check for all checkboxes contain any value, i.e.:
Code: Select all
<cms:if frm_certify ne '{here comes full string of all values}' ><do not perform action></cms:if>

First, check all boxes yourself and remember the string with final ideal result (<cms:dump /> in k_success) then put that ideal string in conditional as above. Good luck :)
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Ah, ok. Thanks!
Mako88 wrote: Ah, ok. Thanks!

Welcome :)
Let us know, please, if you succeeded :)
I haven't seen a similar topics, so your solution might be helpful to someone.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
The way I'd like to do this is

Code: Select all
<cms:if not (field0 && field1 && etc..) />Throw an error</cms:if>
But I'm not sure how to do "not" in an if tag.
Mako88 wrote: The way I'd like to do this is

Code: Select all
<cms:if not (field0 && field1 && etc..) />Throw an error</cms:if>
But I'm not sure how to do "not" in an if tag.

This tag is a bit hidden: viewtopic.php?f=5&t=7377
But you can do 'not's too :)
Code: Select all
<cms:if "<cms:not param />" > ... </cms:if>

or you can default to basic reversed logic:
Code: Select all
<cms:if param='good value' > ..do something <cms:else /> ..don't do </cms:if>
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
OK, it turns out Couch doesn't store the variables individually, so I ended up doing it the way you suggested
Code: Select all
<cms:if frm_certify != 'GED, schoolyear, curriculum, records'>
    <p class="error">You must check all boxes to qualify for the 3rd option.</p>
<cms:else />
7 posts Page 1 of 1