Silverstripe 4 User Defined Form Function


I using your addon (User defined form) at Silverstripe 4.x

At Silverstripe 3.x i am writing you the code which i am adding page.php it is the below

public function ShowForm() {
$record = DataObject::get_one(“UserDefinedForm”, “URLSegment = ‘newsletter-subscribe’”);
$results = new UserDefinedForm_Controller($record);
return $results;

But this is not working at SS 4.x how can i call this function from page.php can you please help me about this issue

This looks like a duplicate of this question: Include userform on page

Unfortunately it hasn’t been solved!

Hi Jonom,

Yes this is not working function.

        $page = UserDefinedForm::get()->filter(['URLSegment' => 'newsletter-subscribe'])->First();
        $form = (new UserDefinedFormController($page))->Form();            
        return $form;

Hi thomos28,

Thank you for the answer. but this function did not work. Server error giving error continuously :frowning:

you need to include namespace as below

use SilverStripe\UserForms\Control\UserDefinedFormController;
use SilverStripe\UserForms\Model\UserDefinedForm;

Hi Tomas28,

I did the joint, but it did not happen again.

you can see the codeblock below.


use SilverStripe\UserForms\Control\UserDefinedFormController;
use SilverStripe\UserForms\Model\UserDefinedForm;

class Newsletter extends UserDefinedForm
    private static $db = [

    private static $has_one = [
	private static $owns = [

class NewsletterController extends UserDefinedFormController {

Please see the below for the demo code, I am using Silverstripe 4.2.1


Thank you very much for your help. I have included form to all pages as you redirected.

We have only one issue, when i create a fields and enter their names, names are changing in the both forms(English-German) while i am trying to translate.

Do you mind sharing your source code.

Translate Module (GitHub - tractorcow/silverstripe-fluent: Multi-language translate module for Silverstripe, without having to manage separate site trees.)
UserDefinedForm Module (

I am using these modules.

I am creating the form as standard UsedDefinedForm.