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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

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

Extending UserDefinedForm

Go to End

4 Posts   2019 Views


Community Member, 323 Posts

9 June 2009 at 1:09am

Edited: 09/06/2009 2:26am


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 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

class InscriptionsPage_SubmittedFormEmail extends UserDefinedForm_SubmittedFormEmail {
	protected $ss_template = "InscriptionsPage_SubmittedFormEmail";
	function __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,


Community Member, 323 Posts

9 June 2009 at 2:53am

I partially reply to myself:

As the process() function in UserDefinedForm creates a new UserDefinedForm_SubmittedFormEmail, I should override also this function, isn't it? Maybe it's impossible to do what I want by subclassing UserDefinedForm…


Forum Moderator, 5523 Posts

9 June 2009 at 5:56pm

You would almost be better Decorating the form rather then subclassing it -


Community Member, 323 Posts

10 June 2009 at 4:59am

Thanks willr, I'll try the Decorator, if I ever understand how it works and applies to the email templates… :)