I have some configuration fields in my addon, one of them I would like to be a dropdown of e-mail templates available in WHMCS. But no info on how to add a funcion in the oficial developer pages on how to setup such a field. Regardless I found another page explaining adding such a field for the rpovisioning module and tried to use it. Code below:
// Select e-mail to send on trial start
'tam-s1' => array (
'FriendlyName' => 'E-mail Template',
'Type' => 'text',
'Size' => '25',
'Loader' => function () {
$command = 'GetEmailTemplates';
$postData = array(
'type' => 'general',
);
$templates = localAPI($command, $postData);
if ($templates['result'] == 'success') {
echo 'Message sent successfully!';
} else {
echo "An Error Occurred: " . $results['result'];
}
print_r($templates,true);
// Format the list of values for display
// array ('value' => 'Display Label'),
$list = [];
foreach ($templates as $emailtemplate) {
$list[$emailtemplate['id']] = ucfirst($emailtemplate['name']);
}
return $list;
},
'SimpleMode' => true,
),
But nothing really happens on the addon configuration page. The field in question prints out as a standard text field. Should I assume that the Loader only works within other fields and not the addon config fields? Or am I doing something wrong?
Thanks in advance.