Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
I'm using a cms:editable of type 'checkbox'. Let's say it's called 'letters', and the values are 'A | B | C'. Now I know that if the user checks only the first two, I'll end up with 'letters' being equal to 'A | B'. So is there an easy way to use cms:if to test for the value containing 'A' or containing 'B' (contains as opposed to being equal to)? Or do I have to go over to native PHP there?
Php, of course, provides some nice commands to manipulate data. It is easy to test if value is in array. However, if you chooses to avoid php for some reason, then cms:each can help.
Code: Select all
<cms:each var=letters as='item' sep='|' >
   <cms:if item='A' || item='B' > A or B are checked! </cms:if>
</cms:each>


If you are a real lover of RegEx, you can construct your own expression to test inputted data.
Code: Select all
<cms:if "<cms:validate value=letters validator='regex..' />">

A basic example may suit your use-case.

Or you can define a completely custom validator. More details about that are in tags.php line 5850. Unfortunately, I have no other source of info on this very powerful option. Nevertheless, I think the previous two options are solving your query.
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
I hadn't thought to use cms:each, which is going to be quite fast enough for a small number of options. Thanks.
3 posts Page 1 of 1