[TYPO3] Filling BE forms with dynamic data
Toby Cooper
tac at pixelis.be
Tue Mar 14 23:56:38 CET 2006
Hi there Typo friends,
I've stumbled upon an issue I just can't seem to resolve.
I'm developping an extended news plugin for which I'm trying to 'autofill'
various input boxes in the BE insert news record form.
I can pull data from a table an send it to a dropdown list, and I can add an
arbitrary default value to an input box, but I can't seem to add dynamic
data to an input box. I've been through the core_doc_api and create
extension docs but just can't find the full answer.
Here is my own class file (class.user_getInfo.php) :
<?
class user_getInfo {
function main(&$params,&$pObj){
$params["items"] = array();
$params['items'][]=
array($GLOBALS['BE_USER']->user['username'],$GLOBALS['BE_USER']->user['usern
ame']);
}
}
?>
And here is my ext_tables file :
<?php
if (!defined ('TYPO3_MODE')) die ('Access denied.');
if (TYPO3_MODE=="BE"){
include_once(t3lib_extMgm::extPath("pixnews")."class.user_getInfo.php");
}
t3lib_div::loadTCA("tt_news");
$tempColumns = Array (
'author' => Array (
'exclude' => 1,
'l10n_mode' => $l10n_mode_author,
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.author',
'config' => Array (
"type" => "select",
"itemsProcFunc" => "user_getInfo->main",
"items" => Array (
Array("",0),
),
"foreign_table" => "be_users",
"foreign_table_where" => "ORDER BY be_users.username",
"size" => 1,
"minitems" => 0,
"maxitems" => 1,
)
),
);
t3lib_extMgm::addTCAcolumns("tt_news",$tempColumns,1);
t3lib_extMgm::addToAllTCAtypes("tt_news","");
...
?>
Now that works, ie it gives me a dropdown list with the current user
selected, but what I would really like to do is something like this :
<?
t3lib_div::loadTCA("tt_news");
$tempColumns = Array (
'author' => Array (
'exclude' => 1,
'l10n_mode' => $l10n_mode_author,
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.author',
'config' => Array (
'type' => 'input',
'size' => '20',
'eval' => 'trim',
'max' => '80',
'default' => $this->user_getInfo->main,
),
),
);
?>
because the following does work (on a new record only, not when editing an
previously created one, that alone took me 3 hours to figure out)
t3lib_div::loadTCA("tt_news");
$tempColumns = Array (
'author' => Array (
'exclude' => 1,
'l10n_mode' => $l10n_mode_author,
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.author',
'config' => Array (
'type' => 'input',
'size' => '20',
'eval' => 'trim',
'max' => '80',
'default' => 'the dude',
),
),
);
Any pointers would be welcome...
And an answer as to why I can't access $GLOBALS['BE_USER']->user['username']
directly from ext_tables.php would be nice too ...
Cheers,
Toby Cooper
More information about the TYPO3-english
mailing list