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:

Form Questions /

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

Custom form question

Go to End

2 Posts   1726 Views


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


Edit: wording.


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