Wondering if its possible to write a custom function to simplify my code. I'm in the process of making a new snippet for my history section of my clinic notes. I find that I'm manually adding the buttons in next to my list selection (add, unselect, select all) for all my lists. Is there a way to make a single function that I can just pass variables (add, select, list) through and have it generate the buttons for me?
{note: trim=yes; preview=no}
Variables/Lists:
Symptoms list: {run: symptoms_list= ["fever", "cough", "sore throat"]}
{endnote: trim=yes}
Symptoms: {note}{formmenu: values={=symptoms_list}; name=symptoms_selected; multiple=yes} {formtext: name=symptoms_add}{button: if symptoms_add = ""
notify("associated_add cannot be blank")
return
endif
symptoms_selected = merge(symptoms_selected, [symptoms_add])
symptoms_add = ""
; label=add}{button: symptoms_selected = [""]
; label=unselect all}{button: symptoms_selected = symptoms_list
; label=select all}{endnote}
- {repeat: for symptom in symptoms_selected}{=symptom}{formtoggle: default=no} - {formtext}{endformtoggle}{if: location( symptoms_selected, symptom)<count( symptoms_selected)}
{endif}{endrepeat}