---
title: "selectFields auch bei TCA-Tabellen?"
url: "https://www.typo3.net/d/83545-selectfields-auch-bei-tca-tabellen"
source: "typo3.net"
tags: ["Backend","Frage"]
created: "2008-11-02"
last_reply: "2008-11-08"
replies: 7
solved: false
page: 1
pages: 1
lang: "de"
---

# selectFields auch bei TCA-Tabellen?

Backend · 7 Antworten · gestartet 2008-11-02

## Eröffnungsbeitrag

**lixx** · 2008-11-02 · [Beitrag #1](https://www.typo3.net/d/83545-selectfields-auch-bei-tca-tabellen/1)

Hallo!

Hätte eine Frage zu der TCA-Tabelle. Kann man dort auch weitere oder ein anderes Feld als den title angeben, die dann in der Auswahlliste angezeigt werden? Soetwas wie z.B. beim TS-Befehl select die selectFields-Funktion.

```php
$tempColumns = Array (
	"tx_commercerelated_related_products" => Array (		
		"exclude" => 1,		
		"label" => "LLL:EXT:commercerelated/locallang_db.xml:tx_commerce_products.tx_commercerelated_related_products",		
		"config" => Array (
			'type' => 'select',
			'internal_type' => 'db',
			'allowed' => 'tx_commerce_products',
			'MM' => 'tx_commerce_products_tx_commercerelated_related_products_mm',
			'foreign_table' => 'tx_commerce_products',
			'foreign_table_where' => ' ORDER BY tx_commerce_products.sorting',
			'size' => 15,
			'minitems' => 0,
			'maxitems' => 99,
		)
	),
);
```

Hoffe einer weiß Rat.

lg lixx

## Antworten

### [#2](https://www.typo3.net/d/83545-selectfields-auch-bei-tca-tabellen/2) · steffenk · 2008-11-02

es gilt immer das label das bei der Tabelle im TCA steht.
In Deinem Beispiel das label das für tx_commerce_products definiert ist.

Abweichend geht nur in einer labelUserFunc oder die komplette select in einer userFunc

### [#3](https://www.typo3.net/d/83545-selectfields-auch-bei-tca-tabellen/3) · lixx · 2008-11-02

Ja, danke! Hat weitergeholfen.

lg lixx

### [#4](https://www.typo3.net/d/83545-selectfields-auch-bei-tca-tabellen/4) · febo · 2008-11-07

Hi steffenk,

hast Du für deinen Lösungsansatz mit der userFunc ein Beispiel. Ich benötige in einer Selectbox mehr Angaben als nur ein Feld, also z.B. **Vorname - Nachname** statt nur den **Nachnamen**. Habe hier auch schon lange gesucht, nur leider bis jetzt nicht fündig geworden.

Danke

Gruß

febo

### [#5](https://www.typo3.net/d/83545-selectfields-auch-bei-tca-tabellen/5) · lixx · 2008-11-08

Nein ;) aber ich hab' eins gerade zur Hand:

```php
<?php
if (!defined ('TYPO3_MODE')) 	die ('Access denied.');
$tempColumns = Array (
	"tx_commercerelated_related_products" => Array (		
		"exclude" => 1,		
		"label" => "LLL:EXT:commercerelated/locallang_db.xml:tx_commerce_products.tx_commercerelated_related_products",		
		"config" => Array (
			'type' => 'select',
			'internal_type' => 'db',
			'allowed' => 'tx_commerce_products',
			'MM' => 'tx_commerce_products_tx_commercerelated_related_products_mm',
			'foreign_table' => 'tx_commerce_products',
			'foreign_table_where' => " AND tx_commerce_products.uid != '###THIS_UID###' ORDER BY tx_commerce_products.sorting",
			'size' => 15,
			'minitems' => 0,
			'maxitems' => 99,
			'itemsProcFunc' => 'user_commercerelated_selection',
		)
	),
);


t3lib_div::loadTCA("tx_commerce_products");
t3lib_extMgm::addTCAcolumns("tx_commerce_products",$tempColumns,1);
t3lib_extMgm::addToAllTCAtypes("tx_commerce_products","tx_commercerelated_related_products;;;;1-1-1");

t3lib_extMgm::addStaticFile($_EXTKEY,'static/defaults/', 'defaults');

function user_commercerelated_selection(&$conf,&$item) {
	if (isset($conf['items'])) {
		$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('subtitle', $conf['config']['foreign_table'], '1'.str_replace('###THIS_UID###', $conf['row']['uid'], $conf['config']['foreign_table_where']));
		while ($row[] = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res));
		foreach ($conf['items'] as $x => $val) {
			$conf['items'][$x][0] .= $row[$x]['subtitle'] ? ', '.$row[$x]['subtitle'] : '';
		}
	}
	return $conf;
}
?>
```

Verwendet mit der ext commercerelated.

Zeile 17 wird die Funktion definiert.
Zeile 29 beginnt die User-Function.
In der Variable $conf ist dann der aktuelle Datensatz zu finden. Aber erst beim zweiten Durchlauf ... warum weiß ich auch nicht ... daher noch die Abfrage "if (isset($conf['items']))"

lg lixx

### [#6](https://www.typo3.net/d/83545-selectfields-auch-bei-tca-tabellen/6) · steffenk · 2008-11-08

Das Beispiel ist aber für itemsProcFunc

Ein Beispiel für labelUserFunc befindet sichj in cal in class.tx_cal_labels.php

```php
$TCA['tx_cal_event']['ctrl']['label_userFunc']="tx_cal_labels->getEventRecordLabel";
```

### [#7](https://www.typo3.net/d/83545-selectfields-auch-bei-tca-tabellen/7) · lixx · 2008-11-08

Es geht doch um das Item und nicht das Label, oder? Das Label ist doch die Überschrift einer Selectbox.

und ...

```php
$TCA['tx_cal_event']['ctrl']
```

... betrifft ja alle Felder der Tabelle.

### [#8](https://www.typo3.net/d/83545-selectfields-auch-bei-tca-tabellen/8) · steffenk · 2008-11-08

febo fragte nach dem Beispiel, und in dem Beispiel das lable für cal events (Liste oder sonst wo)

---

Quelle: „selectFields auch bei TCA-Tabellen?“, typo3.net, https://www.typo3.net/d/83545-selectfields-auch-bei-tca-tabellen
Beiträge von Mitgliedern des Forums. Bitte mit Link auf die Diskussion zitieren.
