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.

All other Modules /

Discuss all other Modules here.

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

Extending Userforms


Go to End


4 Posts   1517 Views

Avatar
JonShutt

Community Member, 244 Posts

31 July 2011 at 10:52am

Hi,

I'm using the userforms module, but I want to extend it to make a 'survey' page type.

I made a file 'SurveyPage.php' in my code folder with

class SurveyPage extends UserDefinedForm { } and
class SurveyPage_Controller extends UserDefinedForm_Controller { }

I'm adding a few extra bits of data to these pages - such as terms, owener, a logo etc. This all works fine, and I can add the extra into to the CMS.

However, when I 'save and publish' in the CMS, I'm just getting an error message.

I'm also trying to make it new page type, so I can make template 'SurveyPage.ss' which I can use to style all the surveys.

Any help appreciated

Avatar
Sphere

Community Member, 46 Posts

31 July 2011 at 11:17am

Please post (a brief version of) the error message. Without that, it's all guessing.

If you didn't already, install Firebug. You should be able to pull more information from the NET or Console.

Avatar
JonShutt

Community Member, 244 Posts

31 July 2011 at 12:05pm

Hi, the error that the CMS gives back is 'Error saving content' -> this is displayed to the right of the 'save and publish' button

using firebug 'net' tab, I can see there is a '500 Internal Server Error' on the post request to /admin/EditForm/

I've set SS_Log::add_writer(new SS_LogEmailWriter('myemail'), SS_Log::ERR), and this emailing with a report saying:

"At line 65 in /home/mydomain/sapphire/forms/HtmlEditorField.php"

Avatar
JonShutt

Community Member, 244 Posts

31 July 2011 at 12:08pm

Solved!

Ok, having worked through all that,

i figured it was because I had:

public static $db = array(
'Terms'=> 'Text'
);

and then:

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Terms', new HTMLEditorField('Terms', 'Terms and Conditions'));
return $fields;
}

the fact I was making a HMTL text area in the CMS, and trying to save into a TXT database field was the problem!
so I just had to change to

public static $db = array(
'Terms'=> 'HTMLText'
);