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.

Template Questions

Form Submission in OnePage Site


Reply

2 Posts   103 Views

Avatar
taotsetung

24 August 2014 at 10:11pm (Last edited: 25 August 2014 4:36am), Community Member, 1 Post

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

28 August 2014 at 9:41pm Forum Moderator, 5511 Posts

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