I'm after a tutorial / advice on how to extend userforms and use updateEmailData rather than edit line 985/990 of UserDefinedForm.php
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(
'updateEmailData',
'index',
'ping',
'Form',
'finished'
);
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']."";
//print_r($emailData);
return $emailData;
}
}
SubmittedFormEmail.ss (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