[TYPO3-german] TCEFORMS in Backendmodul

Kay Strobach typo3 at kay-strobach.de
Mon Dec 14 13:35:27 CET 2009


Hallo zusammen,

ich würde gerne Formulare im TCEForms-Stil, die ja mit typo3/alt_doc.php 
erzeugt werden in einer BE Modul verwenden.

Das Modul muss aufgrund der Eingaben mehrere Datensätze anlegen, es muss 
also mehr als nur das alt_doc script geben. Bis Version TYPO3 4.2 hatte 
ich eine Lösung, die die entsprechenden JavaScriptdateien eingebunden 
hat und dann ein virtuelles TCA erstellt hat. Mit TYPO3 4.3 klappt dann 
die Validierung der Felder nicht mehr :(

Grüße

Kay


Es wäre genial, wenn es für die Zeilen nach //thanks to dimitry dupelov 
eine generische Lösung gebe, die es mir versionsabhängig erlaubt die 
richtigen JavaScript Dateien einzubinden.



$this->TCEforms = t3lib_div::makeInstance('t3lib_TCEforms');
			$this->TCEforms->initDefaultBEMode();
			$this->TCEforms->setNewBEDesign();
			$this->TCEforms->backPath = $GLOBALS['BACK_PATH'];
			$this->TCEforms->doSaveFieldName = 'doSave';
			$this->TCEforms->localizationMode = 
t3lib_div::inList('text,media',$this->localizationMode) ? 
$this->localizationMode : '';	// text,media is keywords defined in TYPO3 
Core API..., see "l10n_cat"
			$this->TCEforms->returnUrl = $this->R_URI;
			$this->TCEforms->palettesCollapsed = 
!$this->MOD_SETTINGS['showPalettes'];
			$this->TCEforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
			$this->TCEforms->enableClickMenu = true;
			$this->TCEforms->enableTabMenu = true;
			
			// Setting external variables:
			if ($GLOBALS['BE_USER']->uc['edit_showFieldHelp']!='text' && 
$this->MOD_SETTINGS['showDescriptions']) {
				$this->tceforms->edit_showFieldHelp='text';
			}
			//thanks to dimitry dupelov
			$content.='
					<script type="text/javascript" 
src="../../../../typo3/contrib/prototype/prototype.js"></script>
					<script type="text/javascript" 
src="../../../../typo3/js/iecompatibility.js"></script>
					<script type="text/javascript" 
src="../../../../typo3/js/clickmenu.js"></script>
					<script type="text/javascript" src="../../../../typo3/md5.js"></script>
					<script type="text/javascript" 
src="../../../../t3lib/jsfunc.evalfield.js"></script>
			';
			#$content=$this->TCEforms->printNeededJSFunctions_top();;
			#$content.='<form action="" method="post" 
enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" 
name="editform" 
onsubmit="document.editform._scrollPosition.value=(document.documentElement.scrollTop 
|| document.body.scrollTop); return TBE_EDITOR.checkSubmit(1);">';
			$content.='<form action="" method="post" id="typo3form" 
enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" 
name="editform" onsubmit="return TBE_EDITOR.checkSubmit(1);">';
			#$content.='<form action="" method="post" 
enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" 
name="editform" >';
			$content.='<input type="hidden" name="uid" 
value="'.intval(t3lib_div::_GP('uid')).'">';

			return $content;
		}
		function TCEFormsField($field) {
			$fieldHTML =@$this->TCEforms->getSingleField_SW('','',array(),$field);
			$fieldLabel=$field['label'];
			$fieldName 
=substr($field['itemFormElName'],1+strrpos($field['itemFormElName'],'['),-1);
			$content.=$this->TCEforms->fieldTemplate;
			$content=str_replace('###BGCOLOR###' 
,$this->TCEforms->colorScheme[0],$content);
			$content=str_replace('###CLASSATTR_1###' 
,'class="'.$this->TCEforms->classScheme[0].'1"',$content);
			$content=str_replace('###FIELD_ITEM###' ,$fieldHTML       ,$content);
			$content=str_replace('###BGCOLOR_HEAD###' 
,$this->TCEforms->colorScheme[0],$content);
			$content=str_replace('###CLASSATTR_2###' 
,'class="'.$this->TCEforms->classScheme[0].'2"',$content);
			$content=str_replace('###FIELD_NAME###'  ,$fieldLabel      ,$content);
			$content=str_replace('###FIELD_HELP_ICON###'  ,''      ,$content);
			$content=str_replace('###FIELD_HELP_TEXT###'  ,''      ,$content);
			$content=str_replace('###FIELD_PAL_LINK_ICON###'  ,''      ,$content);
			$content=str_replace('###FIELD_TABLE###','custom',$content);
			$content=str_replace('###FIELD_FIELD###',$fieldName,$content);
			$content=str_replace('###FIELD_ID###',t3lib_div::_GP('uid'),$content);
			
			return $content;
		}


More information about the TYPO3-german mailing list