Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Extend Userforms

Go to End

2 Posts   1776 Views


Community Member, 99 Posts

17 June 2014 at 9:04pm

I'm after a tutorial / advice on how to extend userforms and use updateEmailData rather than edit line 985/990 of UserDefinedForm.php

$emailData = array(
		//'RegisteredOffice' => Page_Controller::RegisteredOffice(), adding this here would be easy
		"Sender" => Member::currentUser(),
		"Fields" => $submittedFields

$this->extend('updateEmailData', $emailData, $attachments);

mysite -> _config.php

Object::add_extension('UserDefinedForm_Controller', 'MyUserDefinedFormExtension');

mysite -> code -> MyUserDefinedFormExtension.php

class MyUserDefinedFormExtension extends Extension {
	static $allowed_actions = array(
       function updateEmailData($emailData, $attachments){
		$attachments = null;
		$testp = "i am testing";
		//UserDefinedForm_Controller::$emailData = array("TestPass" => $testp);
		$emailData = array("TestPass" => $testp);
		//echo "update called".$emailData['TestPass']."";
		return $emailData;
} (email template)

         TestPass: $TestPass  

If I move TestPass into the emailData array in UserDefinedForm.php it works.
updateEmailData is being called though on MyUserDefinedFormExtension.php as if I print it shows the TestPass variable


Community Member, 99 Posts

24 June 2014 at 2:13am

In case it helps anyone else

mysite >_config.php

Object::add_extension('UserDefinedForm_Controller', 'MyUserDefinedFormExtension');

mysite > code > MysUserDefinedFormExtension.php

 * An Extension to the UserDefinedForm submission process
 * @package userforms
 * Reasoning: 
 * 1. do not touch source code of userforms module.
 * 2. I want to pass data which is captured via the functions in my  Page_Controller into the template
 		eg <% loop  RegisteredOffice  %>  $Adddress1  <% end_loop %>
Mysite > _config.php  contains the following to register this Extended Class
Object::add_extension('UserDefinedForm_Controller', 'MyUserDefinedFormExtension');

class MyUserDefinedFormExtension extends Extension {
	private static $allowed_actions = array(

	public function updateEmailData($emailData, $attachments){
		$attachments = null;
		$registeredoffices = Controller::curr()->RegisteredOffice();
		$footericons = Controller::curr()->getAllFooterIcons();
		$NewData = $emailData;
		$NewData["RegisteredOffice"] = $registeredoffices;
		$NewData["AllFooterIcons"] = $footericons;
		$emailData = $NewData;
		$this->emailData = $NewData;

	return $this->emailData;  //return emailData
	public function updateEmail($email, $recipient, $emailData){
		$emailData = $this->emailData;

also at