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.

Form Questions /

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

Custom form question


Go to End


2 Posts   2100 Views

Avatar
SilverRay

Community Member, 167 Posts

15 May 2009 at 9:41pm

Edited: 16/05/2009 12:01am

OK, simple question. I have this custom form:

	function TestForm() {
		$fields = new FieldSet(
			new TextField('NumA', 'Number A'),
			new TextField('NumB', 'Number B')
		);
		
		$actions = new FieldSet(
			new FormAction('doSubmitNumbers', 'Calculate')
		);

		$form = new Form(
			$this,
			'Form',
			$fields,
			$actions
		);
		return $form;
	}

The only thing I want the function doSubmitNumbers to do, is to perform some calculation (say, add NumA and NumB) and show the result on the page when it redirects back. I know how I would use doSubmitNumbers to save to the database, but I actually don't want to save to the database, just show the result of the calculation... How would I go forward?

Thanks!

Edit: wording.

Avatar
Willr

Forum Moderator, 5523 Posts

18 May 2009 at 7:06pm

doSubmitNumbers doesn't save anything to the database per se, what its used for is "Run doSubmitNumbers() when you have submitted the form" as to what doSubmitNumbers() does - it could write the DB or it could in your case be used to redirect the user and add numbers