Skip to content

Instantly share code, notes, and snippets.

@frans-beech-it
Created July 11, 2014 07:13
Show Gist options
  • Save frans-beech-it/24bf64f3f43c44ff3f6a to your computer and use it in GitHub Desktop.
Save frans-beech-it/24bf64f3f43c44ff3f6a to your computer and use it in GitHub Desktop.
Add dynamic TCA field eval configuration
ext_localconf.php
--------------------
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['getSingleFieldClass'][$_EXTKEY] =
'EXT:' . $_EXTKEY . '/Classes/Hooks/Tceforms.php:Tx_Calendar_Hooks_Tceforms';
Classes/Hooks/Tceforms.php
--------------------
class Tx_Calendar_Hooks_Tceforms
{
public function getSingleField_beforeRender($table, $field, &$row, &$PA)
{
if ($table === 'tx_calendar_domain_model_event' && ($field == 'event_start' || $field == 'event_end')) {
if ($row['full_day']) {
$PA['fieldConf']['config']['eval'] = 'date,required';
} else {
$PA['fieldConf']['config']['eval'] = 'datetime,required';
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment