If you need a ‘create new record’ link in BE of TYPO3 and also need to supply some default values, this is the way;
-
$params = "&edit[$mapTable][123]=new&defVals[$mapTable][name]=banana&defVals[$mapTable][codename]=hajaja";
-
$aOnClick = t3lib_BEfunc::editOnClick($params,‘../../../../’.TYPO3_mainDir);
-
$icon = ‘<img’.t3lib_iconWorks::skinImg($this->doc->backPath,‘gfx/edit2.gif’,”).‘ title="Create secret agent" alt="" style="border:0;" />’;
-
-
//print a pen icon with the link
-
$HTML = ‘<a href="#" onclick="’.$aOnClick.‘">’.$icon.‘</a>’;
-
So, what we do is setting up necessary parameters for alt_doc.php to perform cmd actions. In this example I use;
edit[table name][uid OR pid OR -uid]=command – use uid and the command edit to edit a uid, otherswise (as I do above) use pid and new as command to create a new record in a certain pid. A negative uid together with the new command Creates a new record right after the supplied uid.
defVals[table name][table column]=value – two times. This sets default values for my two fields; name and codename.
Then assemble the parameters with the TYPO3 API call t3lib_BEfunc::editOnClick(); into a javascript call.