AmineBouhaddi1 Posted June 15, 2018 Share Posted June 15, 2018 Hello, please I try to create a provisioning module, and i want to know how can i get predefined values for each package a create using my module this is my code function app_ConfigOptions($params){ return [ // Text field powered by the Loader function 'Package' => [ 'Type' => 'text', 'Size' => '25', 'Loader' => 'centrix_LoaderFunction', 'SimpleMode' => true ] ]; } function app_LoaderFunction(){ // Make a call to the remote API endpoint $ch = curl_init('http://myapp.club/api.php'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); // Check for any curl errors or an empty response if (curl_error($ch)) { throw new Exception('Unable to connect: ' . curl_errno($ch) . ' - ' . curl_error($ch)); } elseif (empty($response)) { throw new Exception('Empty response'); } // We're done with curl so we can release the resource now curl_close($ch); // Attempt to decode the response $packageNames = json_decode($response, true); // Check to make sure valid json was returned if (is_null($packageNames)) { throw new Exception('Invalid response format'); } // Format the list of values for display // ['value' => 'Display Label'] $list = []; foreach ($packageNames as $packageName) { $list[$packageName] = ucfirst($packageName); } return $list; } the idea is I want to get predefined fields for each package I create 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.