Fernandes Guimarães Posted August 17, 2019 Share Posted August 17, 2019 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. 0 Quote Link to comment Share on other sites More sharing options...
Fernandes Guimarães Posted August 17, 2019 Author Share Posted August 17, 2019 I corrected the foreach funcion so that now it returns a proper "ID" => "Description" array of the email templates. But it sill stays as a text input field instead of a nice dropdown list. 'tam-s1' => array ( 'FriendlyName' => 'E-mail Template', 'Type' => 'text', 'Size' => '25', 'Loader' => function () { $templates = localAPI('GetEmailTemplates', array( 'type' => 'product' )); // Format the list of values for display // array ('ID' => 'Display Label'), foreach ( $templates['emailtemplates']['emailtemplate'] as $a ) { $list[$a['id']] = $a['name']; } return($list); }, 'SimpleMode' => true, ), 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.