10389 Posts in 2200 Topics by 1712 members
|Go to End|
29 August 2009 at 12:31am Last edited: 29 August 2009 12:33am
<% control Page(order-form) %>
<% end_control %>
I also tried $Form but both with no result. $Content gives the value of the content field ($UserDefinedForm) instead of the user form.
Do I have to create a custom method for this?
Any ideas? Thanks!
3 September 2009 at 2:33am
I added this function to the Page class
$get = DataObject::get_one('SiteTree', "URLSegment = 'order-form'");
return new UserDefinedForm_Controller($get);
And inside my template
<% control ShowForm %>
<% end_control %>
14 May 2010 at 12:09am
This has been really helpful. The only problem is, when I added the code to my template file (\themes\mytheme\templates\Layout\Page.ss), it adds the form to every page of the site. How do I set the form to only show on a particular page?
(This is my first SS installation so please forgive my ignorance)
23 September 2010 at 5:33am
This is AWESOME.
and useful for lots of other features, not just forms
30 September 2010 at 9:17am Last edited: 30 September 2010 9:17am
The next question is how to make the form reload the same page after submission instead of mysite.com/(url-segment)/finished. And to do so with the success message in place of the form.
1 October 2010 at 3:43am
thats a good question...
also, i would like a hidden field on the form that generates the page title (e.g - $Title) so that i know which page/category the form was submitted via.
does anybody know how i can do this?
i took a look at the template files for userform, but it looks a bit more complex than i was hoping.
i figured i could just add:
<input type="hidden" name="Page" value="$Title" />
to the template...but where?
1 October 2010 at 6:09am Last edited: 1 October 2010 6:09am
The redirect is coming from line756 of userforms/code/UserDefinedForm.php at the end of the process() method of UserDefinedForm_Controller.
The best solution I have right now is to subclass UserDefinedForm and overwrite process() keeping everything the same except for that last line which gets replaced with whatever logic is needed, possibly even a call to another method. This is a kludge though so if anyone has a solution that doesn't involve recreating process() in its entirety I'd love to hear it.
26 July 2011 at 9:36pm
Big thanks to Richie for that code!
|Go to Top|