Output formmenu item even if not checked

Hi,
Am trying to use a dropdown with {formmenu} with the multiple option to list symptoms.
if a symptom is checked, it should be printed.
if symptom is un checked, it should also print, but with a "no" in front of it

a formmenu with "cough, wheezing, headache " as options that would allow to uncheck headache and output: "couch, wheezing, no headache "

Hi @Charles_Dagenais Welcome to the forum! :slight_smile:

First of all, here is a template that AI Write automatically generated for me:

Select symptoms: {formmenu: cough; wheezing; headache; multiple=yes; name=symptoms}

{if: includes(symptoms, "cough")}Cough,{else}No Cough,{endif}
{if: includes(symptoms, "wheezing")}Wheezing,{else}No Wheezing,{endif}
{if: includes(symptoms, "headache")}Headache{else}No Headache{endif}

But I am not a fan of that solution. So, I have a different solution to this question:

{note}{option_values=["Cough", "Wheezing", "Headache"]}
{formmenu: values={=option_values}; multiple=yes; name=items}{endnote: trim=right}
{=join(map(option_values,(value)->value if includes(items, value) else ("No " & lower(value))), "BLAZE_AND")}

This solution is better because it works with any number of options. For each item in the list, it checks whether the item was checked/selected, and if so, it outputs the item as it is. Oherwise, it prefixes No before that option.

Here's a more readable version of this if you'd prefer that:

{note}{option_values=["cough", "wheezing", "headache"]}
{formmenu: values={=option_values}; multiple=yes; name=items}{endnote: trim=right}
{repeat: for value in option_values; trim=yes}
{if: includes(items, value); trim=yes}
{=value}
{else: trim=yes}
No {=value}
{endif:trim=yes},
{endrepeat: trim=yes}