getCurrentAction(); // Initialize extra field value if (empty($taskInfo['sleepTime'])) { if ($currentSchedulerModuleAction->equals(Action::ADD)) { // In case of new task and if field is empty, set default sleep time $taskInfo['sleepTime'] = 30; } elseif ($currentSchedulerModuleAction->equals(Action::EDIT)) { // In case of edit, set to internal value if no data was submitted already $taskInfo['sleepTime'] = $task->sleepTime; } else { // Otherwise set an empty value, as it will not be used anyway $taskInfo['sleepTime'] = ''; } } // Write the code for the field $fieldID = 'task_sleepTime'; $fieldCode = ''; $additionalFields = []; $additionalFields[$fieldID] = [ 'code' => $fieldCode, 'label' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.sleepTime', 'cshKey' => '_MOD_system_txschedulerM1', 'cshLabel' => $fieldID ]; return $additionalFields; } /** * This method checks any additional data that is relevant to the specific task * If the task class is not relevant, the method is expected to return TRUE * * @param array $submittedData Reference to the array containing the data submitted by the user * @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module) * @return bool TRUE if validation was ok (or selected class is not relevant), FALSE otherwise */ public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $schedulerModule) { $submittedData['sleepTime'] = (int)$submittedData['sleepTime']; if ($submittedData['sleepTime'] < 0) { $this->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.invalidSleepTime'), FlashMessage::ERROR); $result = false; } else { $result = true; } return $result; } /** * This method is used to save any additional input into the current task object * if the task class matches * * @param array $submittedData Array containing the data submitted by the user * @param AbstractTask $task Reference to the current task object */ public function saveAdditionalFields(array $submittedData, AbstractTask $task) { $task->sleepTime = $submittedData['sleepTime']; } }