[TYPO3-project-formidable] Image Preview in Editform
Markus Lange
markus.lange at bgm-gmbh.de
Tue Jan 12 18:59:37 CET 2010
Hi Pablo
thank you for your anwser!
> And about adding a delete button for each photo, try embedding the code
> in a renderlet:LISTER.
Unfortunaltely this did not worked for me.
To delete a pic in editmode i figured out the code below and it works
pretty well.
i have to update the record and repaint the form
they might be better ways (but its first time i use formidable and iam
quite impressed!!)
best regards
Markus
<renderlet:BUTTON name="image_delete5" style="width:100px;">
<label>Bild löschen</label>
<onclick runat="ajax" params="uid">
<userobj>
<php><![CDATA[
$formData = $this->oDataHandler->getFormData();
$iImage = $formData['image5'];
$iUid = $this->oDataHandler->_currentEntryId();
$oFileTool = t3lib_div::makeInstance("t3lib_basicFileFunctions");
$sTargetDir = 'uploads/tx_kundenideen/';
$sTargetDir = t3lib_div::fixWindowsFilePath(
$oFileTool->slashPath($oFileTool->rmDoubleSlash($sTargetDir)));
$sPath = $sTargetDir.$iImage;
$sPath = tx_ameosformidable::toRelPath($sPath);
if(file_exists($sPath) && is_dir($sPath) && ($sPath{(strlen($sPath) -
1)} !== "/")) {
$sPath .= "/";
}
$sPath =
tx_ameosformidable::_removeEndingSlash(t3lib_div::getIndpEnv("TYPO3_DOCUMENT_ROOT"))
. "/" . tx_ameosformidable::_removeStartingSlash($sPath);
unlink($sPath)
if($iUid) {
$fields = array();
$fields['image5']='';
$GLOBALS["TYPO3_DB"]->exec_UPDATEquery( "tx_kundenideen_ideen", "uid='"
. $iUid . "'",$fields );
}
return $this->majixRequestEdition($iUid);
]]></php>
</userobj>
</onclick>
</renderlet:BUTTON>
More information about the TYPO3-project-formidable
mailing list