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.

Template Questions /

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

Form Submission in OnePage Site


Go to End


2 Posts   1473 Views

Avatar
taotsetung

Community Member, 1 Post

24 August 2014 at 10:11pm

Edited: 25/08/2014 4:36am

Hello,
I am using silverstripe to create a OnePage Website - all pages are rendered by one main page to create a scrollable website.
So far the site works very well (http://cms.entro-p.com/), however now I need a contact form.
The problem is, due to letting one page render all forms (
<% loop AllChildren %>
$renderWith($ClassName)
<% end_loop%>
)
I cannot use the page controllers.
Rendering the form works by just adding the ContactForm method to the page class that should render the form.
However, I do not know where I should add the submit method - I tried adding it in the custom form class but that did not work. Can anyone help me?

Thanks in advance!

Daniel Eder

EDIT: I solved the problem by adding the form to the page holder class and moving it to the right position using javascript.

Avatar
Willr

Forum Moderator, 5523 Posts

28 August 2014 at 9:41pm

The submit method is able to go into the Form class. You just need to make sure it's an allowed action on the form. Form submission handler will check that it matches a method on your controller, a method in your form then a method on one of your fields.

https://github.com/silverstripe/silverstripe-framework/blob/3.1/forms/Form.php#L320-L343