[TYPO3-formidable] 2.0.421 with 5.3 and editing in Modalbox

Oliver Wand wand at itaw.de
Fri Jan 29 16:54:40 CET 2010


Hi,

Oliver Klee schrieb:

> Care to post the correspoding code?

Of course not, sorry :-)


Here's the XML, PHP class below:



<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<formidable version="2.0.421">

	<meta>
		<name>Editing in a modalbox</name>
		<form formid="test-modaledit"/>
                <debug>false</debug>
		<codeBehind type="php" name="cb1"
path="typo3conf/ext/ow_royalties/res/class.editmodalbox.php" />
	</meta>

	<control>
			<datasources>
				<datasource:DB name="mysource">
					<sql><![CDATA[
						SELECT * from tx_owroyalties_label
					]]></sql>
				</datasource:DB>
			</datasources>
	</control>

	<elements>
		<renderlet:LISTER name="thelist">
			<datasource use="mysource" />
			<columns>
				<column type="renderlet:TEXT" name="name" listHeader="Name" />
                                <column type="renderlet:TEXT" name="lc"
listHeader="LC" />
				<column type="renderlet:BUTTON" label="Edit" name="btnEdit"
sort="false">
					<onclick
						runat="ajax"
						params="rowData::uid"
						cache="false"
						exec="cb1.btnEdit_click()"
					/>
				</column>
			</columns>
		</renderlet:LISTER>

		<renderlet:MODALBOX name="editbox">
			<childs>
				<renderlet:TEXT name="name" label="Name" />
				<renderlet:TEXT name="lc" label="LC" />
				<renderlet:BUTTON name="btnCancel" label="Cancel">
					<onclick runat="client" exec="cb1.btnCancel_click()" />
				</renderlet:BUTTON>
				<renderlet:BUTTON name="btnSave" label="Save and close">
					<onclick
						runat="ajax"
						params="editbox.title, editbox.subtitle"
						cache="false"
						exec="cb1.btnSave_click()"
					/>
				</renderlet:BUTTON>
			</childs>
		</renderlet:MODALBOX>

	</elements>

</formidable>

------------------------------------



<?php
	class editmodalbox {

		/***** event handling methods *****/

		function btnEdit_click() {

			// requesting parameters from the event
			$aParams = $this->oForm->oMajixEvent->getParams();

			// keeping the current uid under the hand
			$this->oForm->oSandBox->iRecordUid = $aParams["uid"];

			// get record from DB
			$aRecord = $this->getRecord($aParams["uid"]);

			// init the modalbox/childs with this record
			$this->oForm->aORenderlets["editbox"]->setValue($aRecord);

			// open the box
			return $this->oForm->aORenderlets["editbox"]->majixShowBox();
		}

		function btnCancel_click() {
			// close the box
			return $this->oForm->aORenderlets["editbox"]->majixCloseBox();
		}

		function btnSave_click() {

			// requesting parameters from the event
			$aParams = $this->oForm->oMajixEvent->getParams();

                        // update in DB
			$GLOBALS["TYPO3_DB"]->exec_UPDATEquery(
				"tx_owroyalties_label",
				"uid='" . $this->oForm->oSandBox->iRecordUid . "'",
				array(
					"name" => $aParams["editbox.name"],
					"lc" => $aParams["editbox.lc"],
				)
			);

			// close the box, and repaints the list
			return array(
				$this->oForm->aORenderlets["editbox"]->majixCloseBox(),
				$this->oForm->aORenderlets["thelist"]->majixRepaint()
			);
		}

		/****** get/set methods *******/

		function getRecord($iUid) {
			$rSql = $GLOBALS["TYPO3_DB"]->exec_SELECTquery(
				"*",
				"tx_owroyalties_label",
				"uid='" . $iUid . "'"
			);

			return $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($rSql);
		}
	}
?>


More information about the TYPO3-project-formidable mailing list