dyne schrieb
Was mache ich falsch?
Hast du deine Funktion auch in ext_tables.php eingebunden?
include_once(t3lib_extMgm::extPath($_EXTKEY).'pi2/class.tx_myext_pi2.php');
Ich habe meine Funktion z.B. in den Ordner pi2 gelegt und binde ihn darĂŒber ein.
Meine flexform_ds.xml liste sieht so aus:
<dbtable>
<TCEforms>
<label>LLL:EXT:myext/locallang_tca.xml:tx_myext.pi_flexform.dbtable</label>
<config>
<type>select</type>
<multiple>1</multiple>
<size>5</size>
<maxitems>10</maxitems>
<autosizemax>5</autosizemax>
<allownonidvalues>1</allownonidvalues>
<selectedListStyle>width:250px</selectedListStyle>
<itemListStyle>width:250px</itemListStyle>
<items type="array"></items>
<itemsProcFunc>tx_myext_pi2->addFieldsToFlexForm</itemsProcFunc>
</config>
</TCEforms>
</dbtable>
Meine pi2-Funktion sieht wie folgt aus:
<?php
/***************************************************************
* Copyright notice
*
* (c) 2007 Ich <meine@email.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Plugin 'BE Localization in FE Form' for the 'gp_belocalize_feform' extension.
*
* @author Ich <meine@email.de>
* @package TYPO3
* @subpackage tx_myext
*/
class tx_myext_pi2 {
var $prefixId = 'tx_myext_pi2'; // Same as class name
var $scriptRelPath = 'pi2/class.tx_myext_pi2.php'; // Path to this script relative to the extension dir.
var $extKey = 'myext'; // The extension key.
function addFieldsToFlexForm ($config) {
//debug($config, "config");
$optionList = array();
$extConfigArray = array();
$TCA = $GLOBALS['TCA'];
//debug($TCA, "TCA");
// Load table config array (TCA)
$i=0;
while(list($table)=each($TCA)) {
$table = strstr($table, 'tx_');
if (isset($table)) $extConfigArray[$table] = $TCA[$table];
if (isset($TCA[$table]['ctrl']['transOrigPointerField'])) {
t3lib_div::loadTCA($table);
$optionList[$i] = array(0 => $table, 1 => $table);
}
$i++;
}
//debug($extConfigArray, "extConfigArr");
$config['items'] = array_merge($config['items'], $optionList);
//debug($config, "config");
return $config;
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/gp_belocalize_feform/pi2/class.tx_gpbelocalizefeform_pi2.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/gp_belocalize_feform/pi2/class.tx_gpbelocalizefeform_pi2.php']);
}
?>
Diese Funktion liest sÀmtlich datenbank-Tabellennamen beginnend mit "tx_" aus und listet diese zur Auswahl in einer multiple selectable selectbox.
vielleicht stimmt bei dir was mit der option list nicht, debugge die dochmal und schaue ob da auch wirklich "key=>value" pairs enthalten sind.
Ein gutes Beispiel ist unter: http://wiki.typo3.org/index.php/Extension_Development,_using_Flexforms#Dynamic_Data_in_Flexforms zu finden.
Da bei mir anfangs auch noch nichts angezeigt wurde, habe ich einfach mal das hier:
$optionList = array();
// add first option
$optionList[0] = array(0 => 'option1', 1 => 'value1');
// add second option
$optionList[1] = array(0 => 'option2', 1 => 'value2');
$config['items'] = array_merge($config['items'],$optionList);
return $config;
anstelle meiner php funktion verwendet. Das hat mir dann die 2 Optionen angezeigt. Anschliessend habe ich meinen Code an diesen angepasst und es lief.
Das die Daten dann auch gespeichert bleiben, musste ich wie "mitchiru" gepostet hat, dieses leere ItemArray angeben und die option "<allownonidvalues>1</allownonidvalues>" setzen.
GrĂŒĂe
Info