2017-03-17 3 views
0

Meine Scheduler-Aufgabe erhält ein zusätzliches Feld. Die Auswahl einer Option in diesem Auswahlfeld funktioniert korrekt, die Aufgabe wird entsprechend ausgeführt. Aber wenn ich die Aufgabe öffne, um sie zu konfigurieren, wird die ursprüngliche Konfiguration nicht angezeigt, sie zeigt immer die erste Option in meinem Auswahlfeld an.AdditionalFieldsProvider speichert die Konfiguration nicht

Das ist meine Klasse:

class AdditionalFieldProviderSocialHubImporter implements \TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface { 
/** 
* This method is used to define new fields for adding or editing a task 
* In this case, it adds an email field 
* 
* @param array $taskInfo Reference to the array containing the info used in the add/edit form 
* @param object $task When editing, reference to the current task object. Null when adding. 
* @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) 
* @return array Array containing all the information pertaining to the additional fields 
*/ 
public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { 
    $additionalFields = array(); 
    if (empty($taskInfo['replaceVideoStreams']) || $taskInfo['replaceVideoStreams'] === 'false') { 
     $taskInfo['replaceVideoStreams'] = 'false'; 
     $optionTrue = ''; 
     $optionFalse = 'selected'; 
    } else { 
     $optionTrue = 'selected'; 
     $optionFalse = ''; 
    } 
    // Write the code for the field 
    $fieldID = 'task_replaceVideoStreams'; 

    $fieldCode = '<select name="tx_scheduler[replaceVideoStreams]" id="' . $fieldID . '"> 
     <option value="false" '.$optionFalse.'>false</option> 
     <option value="true" '.$optionTrue.'>true</option> 
    </select>'; 

    $additionalFields[$fieldID] = array(
     'code' => $fieldCode, 
     'label' => 'LLL:EXT:exutectmaps/Resources/Private/Language/locallang.xlf:tx_exutecmaps_domain_model_feeds.replaceVideoStreams', 
     '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 \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) 
* @return boolean TRUE if validation was ok (or selected class is not relevant), FALSE otherwise 
*/ 
public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { 
    return TRUE; 
} 
/** 
* 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 \TYPO3\CMS\Scheduler\Task\AbstractTask $task Reference to the current task object 
* @return void 
*/ 
public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task) { 
    $task->replaceVideoStreams = $submittedData['replaceVideoStreams']; 
} 
} 

Antwort

0

etwa wie folgt zu Beginn Ihrer getAdditionalFields() Methode hinzufügen - $taskInfo enthält nur Werte in dem Client übermittelt, wenn das Hinzufügen oder eine Aufgabe bearbeiten, haben diese Werte sein zuerst initialisiert.

// assign default value 
if (!isset($taskInfo['replaceVideoStreams'])) { 
    $taskInfo['replaceVideoStreams'] = 'false'; 
    // assign value of task currently being edited 
    if ($parentObject->CMD === 'edit') { 
     $taskInfo['replaceVideoStreams'] = $task->replaceVideoStreams; 
    } 
} 

den Code eines example in the TYPO3 core ist ähnlich der und betrifft den Befehl add zusätzlich.

Verwandte Themen