inherit
231603
0
Sept 14, 2022 13:26:41 GMT -8
User
37
May 2016
ghosthybros
|
Post by User on Feb 9, 2018 16:45:54 GMT -8
How I can detect if a custom profile field checkbox is checked in layout templates?
|
|
#eb7100
33409
0
1
Apr 29, 2024 9:53:44 GMT -8
Brian
48,129
November 2004
smashmaster3
|
Post by Brian on Feb 9, 2018 22:29:16 GMT -8
Hi, User . Checkbox custom fields behave the same as every other custom field in that whatever options you have checked in them determine the value they output to $[user.custom_field.value] in the custom field loop. If you have three different checkboxes in a single custom field and they're all checked $[user.custom_field.value] would output their values in a comma-separated list like so: There's no easy way to detect if a single checkbox is checked in a custom field that contains multiple checkboxes since you would also have to check for every possible combination of the list that includes that checkbox's value among its items. However, if your custom field has only a single checkbox then it's incredibly easy to detect if it's been checked. In a {foreach} loop for custom fields check if the loop is currently checking against the custom field that contains the checkbox and check if its value is equal to the value of the checkbox. Note that if no checkboxes are checked in the custom field it won't even be included in the custom field loop, so there's unfortunately no way to detect if the checkbox is unchecked.
|
|