[TYPO3-mvc] Fill TCA field default with be_user realName
Henk Scholten
henk at wolfsstyle.nl
Thu Jan 23 11:27:31 CET 2014
Found the solution:
ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication']
= array(
'className' => 'Vendor\\Bla\\Xclass\\BackendUserAuthentication',
);
Classes/Xclass/BackendUserAuthentication.php
<?php
namespace Vendor\Bla\Xclass;
class BackendUserAuthentication extends
\TYPO3\CMS\Core\Authentication\BackendUserAuthentication {
/**
* Sets some defaults for tx_bla_domain_model_download (full name)
* based on the current user
*
* @return void
*/
function fetchGroupData() {
if ($this->user['uid']) {
$this->TSdataArray[] = '
// Setting defaults for tx_bla_domain_model_download author
TCAdefaults.tx_bla_domain_model_download.author =
'.$this->user['realName'].'
';
}
parent::fetchGroupData();
}
}
?>
Henk
Henk Scholten schreef op 17-01-14 17:27:
> Nobody?
>
> Henk Scholten schreef op 15-01-14 19:58:
>> Sorry for my misunderstanding.
>> I tried it with:
>>
>> public function getSingleField_preProcess($table, $field, array &$row,
>> $altName, $palette, $extra, $pal, t3lib_TCEforms $parentObject) {
>> if ($table == 'tx_treg_domain_model_download') {
>> if (empty($row['author'])) {
>> $row['author'] = $GLOBALS['BE_USER']->user['realName'];
>> }
>> }
>> }
>>
>> But now the author only get filled after the form is submitted. I want
>> to fill the author field default by each new download.
>> Is this possible?
>>
>> Regards,
>> Henk
>>
>> Philipp Gampe schreef op 15-01-14 19:19:
>>> Hi Henk,
>>>
>>> Henk Scholten wrote:
>>>
>>>> However the approach tt_news using is not working in TYPO3 6.2
>>>
>>> I said ext:news not ext:tt_news. Anyway here is a direct link:
>>>
>>> https://git.typo3.org/TYPO3v4/Extensions/news.git/blob/HEAD:/Classes/Hooks/Tceforms.php
>>>
>>>
>>>
>>> The hook pre-calculates the archive time based on the current time
>>> and an
>>> offset which must be defined in pageTS.
>>> It is a good example on how you can set any default value, even complex
>>> ones.
>>>
>>> Best regards
>>>
>>
>
More information about the TYPO3-project-typo3v4mvc
mailing list