[TYPO3-english] TCA conditional selects
Oliver Klee
typo3-german-02 at oliverklee.de
Thu Mar 4 17:07:23 CET 2010
Hi,
MantasK schrieb:
> Is it possible with tca to have conditional select inputs, for example,
> in first one I select country and in the second one only cities from
> selected country is listed? I cannot find any example with it :/
I do this via a user function:
tca.php:
'district' => array(
'displayCond' => 'FIELD:city:>:0',
'exclude' => 0,
'label' => 'LLL:EXT:realty/locallang_db.xml:tx_realty_objects.district',
'config' => array(
'type' => 'select',
'itemsProcFunc' => 'tx_realty_Tca->getDistrictsForCity',
...
tx_realty_Tca::
/**
* Gets the districts for a certain city.
*
* @param array $data the TCEforms data, must at least contain [row][city]
*
* @return array the TCEforms data with the districts added
*/
public function getDistrictsForCity(array $data) {
$items = array(array('', 0));
$districs = tx_oelib_MapperRegistry::get('tx_realty_Mapper_District')
->findAllByCityUidOrUnassigned($data['row']['city']);
foreach ($districs as $district) {
$items[] = array($district->getTitle(), $district->getUid());
}
$data['items'] = $items;
return $data;
}
Oli
--
Certified TYPO3 Integrator | TYPO3 Security Team Member
More information about the TYPO3-english
mailing list