Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to call a function from checkboxSetField template

Go to End



Community Member, 7 Posts

2 June 2017 at 12:14pm

Edited: 02/06/2017 12:58pm

I have a form with a checkboxSetField list which works as expected.
For each checkbox item in the loop I want to call a method, I know this is out of scope so I have created an extension.



class OperatorFormExtension extends DataExtension {
    public function testing($ID) {
      return 'hello - '.$ID;

    <% loop $Options %>
        <input id="$ID" class="checkbox" name="$Name" type="checkbox" value="$Value.ATT"<% if $isChecked %> checked="checked"<% end_if %><% if $isDisabled %> disabled="disabled"<% end_if %> />
        <label for="$ID">$Title, testing('myParam')</label><br>
    <% end_loop %>

When I call the method as above I don't get anything displayed on the page.
If I extend the Form class instead of CheckboxSetField I can call the testing method from the form but still not from the checkboxSetField template.

How do I call a method from the template?