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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

UserDefinedForm - new Action


Go to End


3 Posts   709 Views

Avatar
Silverfish

Community Member, 59 Posts

7 January 2012 at 6:36am

Hi There,

i wonder if / how it's possible to add another action than sending an email to an UserDefinedForm (i.e. entering something into a db table).

Any hints anyone?

Regards
S.F.

Avatar
Willr

Forum Moderator, 5523 Posts

7 January 2012 at 8:52pm

One way you can do that is to add a DataObjectDecorator to the SubmittedForm object and hook into the onBeforeWrite of the submittedform object to write the data to your other table.

Avatar
Silverfish

Community Member, 59 Posts

8 January 2012 at 5:02am

Edited: 08/01/2012 5:03am

Hi Willr,

thx for your answer.

since I need several different actions (sendig additional mails and more..), an even migth want to define them by the page, I extendend UserDefinedForm and overwrote the process method of it's controller like:

class FormPage_Controller extends UserDefinedForm_Controller {

function process($data, $form) {

	if ( $something ) {
		$this->doSomething();
	}
	if ( $somethingElse ) {
		$this->doSomethingElse();
	}

	return parent::process($data, $form);
}

This currently seeems to work pretty fine for me.
Just wanted to mention if someone else is having this prob.

Regards (and still a happy new year! ;))
S.F.