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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

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

Workaround for bug in UserForm 0.2 which affects the creation of fields in translated forms in SS 2.3.2

Go to End

7 Posts   2777 Views


Community Member, 127 Posts

27 July 2009 at 3:29pm

Edited: 02/09/2009 4:05pm

There is a bug in the current UserForm 0.2 code which affects translated forms in SS 2.3.2, and which has the effect that form fields and email addresses cannot be added to the translated forms.

The following is explaining in more detail how to workaround the bug in UserForms 0.2, as Juanitou and kateh are discussing it there and on the following pages.

I'm assuming that you have already created a complete form, defined the fields and added the e-mail addresses to send it to. Further I assume you have already created the basic translated from, however you could not add any fields to it, nor could you add the e-mail addresses to which to send the submitted forms.

The quickest and in my eyes easiest way to add the fields for the translated forms is to access your silver stripe database in PHPMyAdmin.

On the left side you see the table names listed. Click on table UserDefinedForm. and then on the top on Browse. Here you see the forms you have created so far. There should be (at least) one record for the original form and one record for the translated form. Look at the field ID for both records and note them.

To create the fields click on the table EditableFormField. on the left side. In the frame on the right side you will see the structure of this table. Click on Browse and you will see the fields you have created so far. You see their names in the field name. Have a look at the field ParentID, the number you see there refers to the forms to which they belong.

Now click on Export, and without changing the defaults click on Go. Among other things it will show you an insert statement similar to the one below:

INSERT INTO `EditableFormField` (`ID`, `ClassName`, `Created`, `LastEdited`, `Name`, `Title`, `Default`, `Sort`, `Required`, `CanDelete`, `CustomErrorMessage`, `CustomRules`, `CustomSettings`, `ParentID`) VALUES
(1, 'EditableTextField', '2009-07-24 22:53:50', '2009-07-25 22:06:38', 'EditableTextField1', 'Your Name', NULL, 1, 1, 1, NULL, 'a:0:{}', 'a:5:{s:4:"Size";s:2:"32";s:9:"MinLength";s:1:"0";s:9:"MaxLength";s:2:"50";s:4:"Rows";s:1:"1";s:10:"ShowOnLoad";s:4:"Show";}', 2),
(2, 'EditableEmailField', '2009-07-24 22:55:08', '2009-07-25 22:06:38', 'EditableEmailField2', 'Your E-mail Address', NULL, 2, 1, 1, NULL, 'a:0:{}', 'a:1:{s:10:"ShowOnLoad";s:4:"Show";}', 2),
(3, 'EditableTextField', '2009-07-24 22:55:41', '2009-07-25 22:06:38', 'EditableTextField3', 'Your Message', NULL, 3, 1, 1, NULL, 'a:0:{}', 'a:5:{s:4:"Size";s:2:"32";s:9:"MinLength";s:1:"0";s:9:"MaxLength";s:4:"1000";s:4:"Rows";s:1:"6";s:10:"ShowOnLoad";s:4:"Show";}', 2);

Copy that your text editor, and now change:

  • if the field ID (the first one) contained 1, 2, and 3, as in this example, change it to 4, 5, and 6, or accordingly.
  • translate the field Name, this is the label which will be shown for the field.
  • in the field ParentID (the last one) change the number (in my example 2) to the ID of the translated form (in my example 5), which you noted earlier.

As an example, now it could look like this:

INSERT INTO `EditableFormField` (`ID`, `ClassName`, `Created`, `LastEdited`, `Name`, `Title`, `Default`, `Sort`, `Required`, `CanDelete`, `CustomErrorMessage`, `CustomRules`, `CustomSettings`, `ParentID`) VALUES
(4, 'EditableTextField', '2009-07-24 22:53:50', '2009-07-25 22:06:38', 'EditableTextField1', 'Ihr Name', NULL, 1, 1, 1, NULL, 'a:0:{}', 'a:5:{s:4:"Size";s:2:"32";s:9:"MinLength";s:1:"0";s:9:"MaxLength";s:2:"50";s:4:"Rows";s:1:"1";s:10:"ShowOnLoad";s:4:"Show";}', 8),
(5, 'EditableEmailField', '2009-07-24 22:55:08', '2009-07-25 22:06:38', 'EditableEmailField2', 'Ihre E-mail Adresse', NULL, 2, 1, 1, NULL, 'a:0:{}', 'a:1:{s:10:"ShowOnLoad";s:4:"Show";}', 8),
(6, 'EditableTextField', '2009-07-24 22:55:41', '2009-07-25 22:06:38', 'EditableTextField3', 'Ihre Nachricht', NULL, 3, 1, 1, NULL, 'a:0:{}', 'a:5:{s:4:"Size";s:2:"32";s:9:"MinLength";s:1:"0";s:9:"MaxLength";s:4:"1000";s:4:"Rows";s:1:"6";s:10:"ShowOnLoad";s:4:"Show";}', 8);

Click on SQL on top, a text field will be shown. Replace whatever is shown there ("SELECT ...") with the insert statement which you just edited.

Click on Go.

Assuming there are no typos and no error messages the fields will now show up in the translated form :)

To add the e-mail address to send the form to we need to do the same in the table UserDefinedForm_EmailRecipient.

Again here an example of the insert statement which you get when you export that table:

INSERT INTO `UserDefinedForm_EmailRecipient` (`ID`, `ClassName`, `Created`, `LastEdited`, `EmailAddress`, `EmailSubject`, `EmailFrom`, `EmailBody`, `SendPlain`, `FormID`, `SendEmailFromFieldID`, `SendEmailToFieldID`) VALUES
(1, 'UserDefinedForm_EmailRecipient', '2009-07-24 10:30:50', '2009-07-24 10:30:50', '', 'Contact Form of', '', NULL, 0, 2, 0, 0);

Assuming you want the same e-mail address as recipient for both forms, all you need to do is to change the field FormID (the third to last field), as done here:

INSERT INTO `UserDefinedForm_EmailRecipient` (`ID`, `ClassName`, `Created`, `LastEdited`, `EmailAddress`, `EmailSubject`, `EmailFrom`, `EmailBody`, `SendPlain`, `FormID`, `SendEmailFromFieldID`, `SendEmailToFieldID`) VALUES
(1, 'UserDefinedForm_EmailRecipient', '2009-07-24 10:30:50', '2009-07-24 10:30:50', '', 'Contact Form of', '', NULL, 0, 8, 0, 0);

Then click again on SQL on top and do as before.

That's it, I hope it helps until UserForms 0.2 is fixed.


Community Member, 50 Posts

4 August 2009 at 3:40am

Thank you. This hack helps me a lot.


Community Member, 323 Posts

27 August 2009 at 2:14am

Dear Kalileo, thanks for the effort, I should have done it myself. I hope that the new version of the module will be published soon.

Best regards,


Community Member, 127 Posts

2 September 2009 at 4:20pm

:) You're welcome, dab and Juan

BTW, the javascript form validation does not work in the KDE browser, Konqueror. It works in Firefox though. If you look at the page source code, the javascript validation code seems to be added twice at the end of the page :o


Community Member, 14 Posts

16 November 2009 at 1:17am

Could someone please tell me if they have written a script to do this?

If someone have some script to copy the form from the English to any other language it would be great.

Please share.


Community Member, 14 Posts

24 November 2009 at 10:00pm

Here is a hack to copy a form from the original language.

In the templates/FieldEditor.css

        <% if Fields %>
        <% else %>
        <div class="">
                <h3>Importing from original form</h3>
                <input rel="$theparentid" class="importingOriginalForm" type="button" value="Import now">
        <% end_if %>

In the userforms/javascript/UserForm.js

                * Importing form data
                $(".importingOriginalForm").livequery('click', function() {
                        statusMessage("Importing from original form");

                        var parent = $(this).attr("rel");
                        var action = 'admin/duplicatethisform/'+parent;
                                type: "GET",
                                url: action,
                                data: "parentID=0&ajax=1",
                                // create a new field
                                success: function(msg){
                                        statusMessage("Importing form successfull");

                                // error creating new field
                                error: function(request, text, error) {
                                        statusMessage("Importing form failed");
                        return false;


 function duplicatethisform() {
                 if(($id = $this->urlParams['ID']) && is_numeric($id)) {
                        $page = DataObject::get_by_id("SiteTree", $id);
                        if($page && !$page->canEdit()) return Security::permissionFailure($this);

                        $newPage = $page->getTranslation(Translatable::default_locale());
                                foreach($newPage->Fields() as $field) {
                                        $newField = $field->duplicate();
                                        $newField->ParentID = $page->ID;
                                foreach($newPage->EmailRecipients() as $recipient) {
                                        $newER = $recipient->duplicate();
                                        $newER->FormID = $page->ID;
                         return $this->returnItemToUser($page);
                } else {
                        user_error("CMSMain::duplicatethisform() Bad ID: '$id'", E_USER_WARNING);



Community Member, 8 Posts

21 February 2010 at 5:20am

I picked up your useful concept here but I get this error (using SS 2.3.6):

syntax error
[Break on this error] if($id = $this->urlParams['ID'] && is_numeric($id)){\n

Can you hep?