Hi!
I'm not good at PHP. I'm trying to extend UserDefinedForm for one added feature: being able to count the number of form submissions and print it in the mail message sent to the client.
It's quite easy to get this count done in the page controller (InscriptionsPage.php):
class InscriptionsPage extends UserDefinedForm {
static $add_action = "formulaire pour divers inscriptions";
static $icon = "cms/images/treeicons/task";
}
class InscriptionsPage_Controller extends UserDefinedForm_Controller {
function InscriptionsResults() {
$submissions = DataObject::get('SubmittedForm', "ParentID = $this->ID");
$total = $submissions->Count();
return $total;
}
}
Now, in InscriptionsPage.ss I can use $InscriptionResults in order to print the number of submissions (even if I have no use for that), but I'm not being able to use $InscriptionResults in the email submitted to the page owner. Ideally, I'd like to have a specific template for this form, but I'm not even being able to overload the default template SubmittedFormEmailToSubmitter.ss:
class InscriptionsPage_SubmittedFormEmail extends UserDefinedForm_SubmittedFormEmail {
protected $ss_template = "InscriptionsPage_SubmittedFormEmail";
function __construct() {
parent::__construct();
}
Could someone please help me in those basic tasks: accessing the function InscriptionsResults() outside the page (i.e. in the email template) and using a specific template instead of the default one for this email.
Thanks in advance,
Juan