Jump to:

10928 Posts in 2612 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Extending Userforms

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 964 Views
  • Futureweb
    Avatar
    Community Member
    232 Posts

    Extending Userforms Link to this post

    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

  • Sphere
    Avatar
    Community Member
    44 Posts

    Re: Extending Userforms Link to this post

    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.

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: Extending Userforms Link to this post

    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"

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: Extending Userforms Link to this post

    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'
       );

    964 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.