[TYPO3] itemsProcFunc problem
Vincent Mans
typo3.vincnet at gmail.com
Sun Sep 2 12:21:05 CEST 2007
It's partly solved, thanks to gupf
http://www.typo3.net/index.php?id=13&action=list_post&tid=64410, and see
code listing below.
I manage now to fetch string values from the foreign table to this table. It
works for "maxitems" => 1 and for "maxitems" => more than 1. This table
gets filled nicely, and if more than 1, values are comma separated. However:
- in case of 1, the selected item is nicely marked in the BE select
box
- in case of more than 1, nothing is returned to the BE selected items
field, so from there I see no selection once the record is saved
I know the maxitems definition (1 or more than 1) decides which selectbox is
used, and that it's basic handled differently. Does anyone have an idea to
solve this last detail? I tried several things already, no results. Of
course I try further.
Config part in the TCA:
"config" => Array (
"type" => "select",
"size" => 9,
"minitems" => 0,
"maxitems" => 2, // works 100% only with => 1
"itemsProcFunc" => "tx_ttnews_itemsProcFunc->user_select",
"itemsProcFunc_config" => array(
"table" => "tt_news_xsign",
"sortField" => "title",
"indexField" => "title",
),
"allowNonIdValues" => 1,
In the class:
function user_select($params) {
global $TCA, $TYPO3_DB, $LANG;
$items = $params['items'];
$config = $params['config'];
$table = $config['itemsProcFunc_config']['table'];
$sortField = $config['itemsProcFunc_config']['sortField'];
$indexField = $config['itemsProcFunc_config']['indexField'];
$query = 'SELECT uid, '.$sortField.', '.$indexField.' FROM
'.$table.' ORDER BY '.$sortField.t3lib_pageSelect::enableFields($table);
$res = mysql(TYPO3_db,$query);
while($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$params['items'][$row['uid']]=array($row[$sortField],$row[$indexField]);
}
}
More information about the TYPO3-english
mailing list