[TYPO3-formidable] Re-Render form in actionlet to send content by mail

Martin Terber mail at martinterber.com
Thu Sep 22 15:39:54 CEST 2011


Hi there, we have a setup where we use Formidable with a typoscript setup (with initFromTs).
Rendering new forms and getting form content from database into the template work fine on seperate pages.

What I need to do now is to send the form content, once the data is submitted, by email. I created an actionlet for that:

actionlets {
	5 = actionlet:USEROBJ
	5.userobj {
		extension = this
		method = sendRequestNotification
	  }

and in our extension class, I created a method that sends away the email notifications:

public function sendRequestNotification() {
		[...]
		// Get form data from previously created request:
	    	$row =   $this->form->aRawPost['formular'];
		[...]
		// 1. get mail template html code
		$message =  $this->renderTemplate($row);
		$result = $this->ext->wrappedMailSender($toMail, $subject, $message, $fromEMail, $fromName = 'Sender's nam');
		[...]
	}


public function renderTemplate($row) {
		[...]
   		$this->form->initFromTs(
			$this,
			$this->conf['form.']['formname.'],
			$this->requestId
		);
		$result = $this->form->render();
		[...]
	}

However, when trying to re-render the form, I get the error message:

	Formidable::Mayday
	Two (or more) renderlets are using the same name 'fieldname' on this form ('formular') - cannot continue
	Inclusions: EMPTY!

This happens when I call the render() function.
It is thrown because rendering a form with an existing renderlet structure is forbidden - unless a overwrite flag is set in function _makeRenderlets:
 > function _makeRenderlets($aConf, $sXPath, $bChilds, &$oChildParent, *$bOverWrite = FALSE*)

Does someone know:
- How to avoid that Mayday Error? or
- How to set the Overwrite flag ("bOverWrite") when calling the API?


Greets:
Martin Terber
www.martinterber.com

				


More information about the TYPO3-project-formidable mailing list