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.

Archive /

Our old forums are still available as a read-only archive.

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

UserDefinedForm


Go to End


5 Posts   2897 Views

Avatar
redking

43 Posts

19 March 2008 at 6:44am

Hi,

Is there a way to create a UserDefinedForm with another pagetype other than "contact form?" I am already using contact form, and need to be able to create forms on other pages within the CMS. Can someone please help me figure out how this is done?

Thanks!

Avatar
(deleted)

Community Member, 473 Posts

19 March 2008 at 7:22am

The third tutorial shows how to create a form inside a page.

Avatar
redking

43 Posts

19 March 2008 at 8:22am

Right...But is there a way to make use of the UserDefinedForm class with other pagetypes other than the "contact form" pagetype? Creating a custom form pagetype is an option, I suppose; however I'd like the ability to manage it through the CMS.

The reason I want to use another pagetype in conjunction with the UserDefinedForm class is so I can create different forms on different pages.

Hopefully that makes sense.

Any ideas?

Thx!

Avatar
Hayden

Core Development Team, 19 Posts

19 March 2008 at 4:31pm

The easiest way to do this would be to subclass

UserDefinedForm
directly and create a new page type from that. You can subclass the
UserDefinedForm_Controller
directly as well:

<?php
class YourFormPageType extends UserDefinedForm {

static $add_action = 'my page type';

// Any other custom code

?>

This should behave the same way as a contact form, but will appear to be a different type of page in the CMS.

Avatar
Garrett

Community Member, 245 Posts

5 August 2008 at 7:15am

Hi,

I had/have a similar issue. I need a separate TEMPLATE for my form; I.e.: other than Page.ss, for reasons too complicated and boring to go into. SO-- I have followed your advice and created a new pagetype ("ContactForm[.php]") and rebuilt my database and change the pagetype to the new one. My form is all still there in the CMS so I know the extends is working fine.

I also then created my ContactForm.ss template, and coded my special layout. The template is being accessed and used (showtemplate=1). So we're good there. However, for some very frustrating reason, the form I built inside the CMS is not showing up! Although $Content is benig picked up, $Form seems to have NO effect.

What am I doing wrong?

Thanks in advance,
Garrett