Zum Inhalt springen

Eigener Wizard mit userFunc / Javascript reagiert nicht

Erstellt am 1. Februar 2016 · Noch keine Antworten

Tags: Frage

poveli ·

Hallo Leute, ich habe von der TYPO3-Seite folgenden Code gefunden, der mir sehr weiterhelfen könnte, wenn er funktionieren würde: https://docs.typo3.org/m/typo3/reference-tca/main/en-us/ColumnsConfig/CommonProperties/FieldControl/Index.html

'weirdness' => array(
        'exclude' => 0,
        'label' => 'LLL:EXT:examples/Resources/Private/Language/locallang_db.xlf:tx_examples_haiku.weirdness',
        'config' => array(
                'type' => 'input',
                'size' => 10,
                'eval' => 'int',
                'wizards' => array(
                        'specialWizard' => array(
                                'type' => 'userFunc',
                                'userFunc' => 'Documentation\\Examples\\Userfuncs\\Tca->someWizard',
                                'params' => array(
                                        'color' => 'green'
                                )
                        )
                )
        )
),
public function someWizard($PA, $fObj) {
        // Note that the information is passed by reference,
        // so it's possible to manipulate the field directly
        // Here we highlight the field with the color passed as parameter
        $backgroundColor = 'white';
        if (!empty($PA['params']['color'])) {
                $backgroundColor = $PA['params']['color'];
        }
        $PA['item'] = '<div style="background-color: ' . $backgroundColor . '; padding: 4px;">' . $PA['item'] . '</div>';

        // Assemble the wizard itself
        $output = '<div style="margin-top: 8px; margin-left: 4px;">';

        $commonJavascriptCalls = $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] . $PA['fieldChangeFunc']['typo3form.fieldGet'] . ' return false;';
        // Create the + button
        $onClick = "document." . $PA['formName'] . "['" . $PA['itemName'] . "'].value++; " . $commonJavascriptCalls;
        $output .= '<a href="#" onclick="' . htmlspecialchars($onClick) . '" style="padding: 6px; border: 1px solid black; background-color: #999">+</a>';
        // Create the - button
        $onClick = "document." . $PA['formName'] . "['" . $PA['itemName'] . "'].value--; " . $commonJavascriptCalls;
        $output .= '<a href="#" onclick="' . htmlspecialchars($onClick) . '" style="padding: 6px; border: 1px solid black; background-color: #999">-</a>';
        $output .= '</div>';
        return $output;
}

Es wird ein eigenes Input-Feld erzeugt, das mit + und - bedient werden kann. Das Feld wird angelegt, auch die Farbe grün wird angezeigt. Allerdings reagiert der Klick auf + und - überhaupt nicht. In der Browser-Konsole werden keine Fehler ausgeworfen. Ist es für die Version 7.6 veraltet?

Danke für euren Support.