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.

All other Modules /

Discuss all other Modules here.

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

2.3.1 upgrade - UserForms failing - setCustomValidationMessage


Reply


7 Posts   1363 Views

Avatar
Double-A-Ron

Community Member, 604 Posts

27 April 2009 at 9:55am

Hi there,

I am trying to upgrade a site from 2.2.3 to 2.3.1 and I am having trouble with making the existing forms work with the UserForms module.

There are two errors. One on the public side, one on the CMS side:

1. No contact page will display on the public side and instead I get an error like this:

[User Error] Object::__call() Method 'setCustomValidationMessage' not found in class 'TextField'
GET /contact-us/?isDev=1

Line 133 in C:\wamp\www\viva_exp_2.3\sapphire\core\Object.php
Source

124
125          } else if($config['function_str']) {
126             $function = Object::$extraMethods[$this->class][strtolower($methodName)]['function'] = create_function('$obj, $args', $config['function_str']);
127             return $function($this, $args);
128
129          } else {
130             user_error("Object::__call() Method '$methodName' in class '$this->class' an invalid format: " . var_export(Object::$extraMethods[$this->class][$methodName],true), E_USER_ERROR);
131          }
132       } else {
133          user_error("Object::__call() Method '$methodName' not found in class '$this->class'", E_USER_ERROR);
134       }
135    }
136
137    /**
138     * This function allows you to overload class creation methods, so certain classes are
139     * always created correctly over your system.

Trace

* Object::__call() Method 'setCustomValidationMessage' not found in class 'TextField'
Line 133 of Object.php
* Object->__call(setCustomValidationMessage,Array)
* TextField->setCustomValidationMessage('Firstname' is required.)
Line 297 of UserDefinedForm.php
* UserDefinedForm_Controller->Form()
Line 253 of UserDefinedForm.php
* UserDefinedForm_Controller->index(HTTPRequest)
Line 162 of Controller.php
* Controller->handleAction(HTTPRequest)
Line 107 of RequestHandler.php
* RequestHandler->handleRequest(HTTPRequest)
Line 122 of Controller.php
* Controller->handleRequest(HTTPRequest)
Line 28 of ModelAsController.php
* ModelAsController->handleRequest(HTTPRequest)
Line 277 of Director.php
* Director::handleRequest(HTTPRequest,Session)
Line 121 of Director.php
* Director::direct(/contact-us/)
Line 115 of main.php

2. On the CMS side, there is a new tab called "Recipients", which I assume is where submissions from the form are sent. (Even though it doesn't state anywhere on the tab exactly what it's for). When trying to add a recipient, I get this:

[Warning] HTMLEditorField should save into an HTMLText or HTMLVarchar field. If you don't, your template won't display properly. This changed in version 2.2.2, so please update your database field 'EmailBody'
POST /admin/EditForm/field/EmailRecipients/AddForm

Line 98 in C:\wamp\www\viva_exp_2.3\sapphire\forms\HtmlEditorField.php
Source

89    }
90    
91    function saveInto($record) {
92       if($record->escapeTypeForField($this->name) != 'xml') {
93          user_error("HTMLEditorField should save into an HTMLText or HTMLVarchar field.
94             If you don't, your template won't display properly.
95             This changed in version 2.2.2, so please update
96             your database field '$this->name'",
97             E_USER_WARNING
98          );
99       }
100       
101       $content = $this->value;
102       
103       $content = preg_replace('/mce_real_src="[^"]+"/i', "", $content);
104       

Trace

* HTMLEditorField should save into an HTMLText or HTMLVarchar field. If you don't, your template won't display properly. This changed in version 2.2.2, so please update your database field 'EmailBody'
Line 98 of HtmlEditorField.php
* HtmlEditorField->saveInto(UserDefinedForm_EmailRecipient)
Line 850 of Form.php
* Form->saveInto(UserDefinedForm_EmailRecipient)
Line 581 of ComplexTableField.php
* ComplexTableField->saveComplexTableField(Array,ComplexTableField_Popup,HTTPRequest)
Line 228 of Form.php
* Form->httpSubmission(HTTPRequest)
Line 107 of RequestHandler.php
* RequestHandler->handleRequest(HTTPRequest)
Line 121 of RequestHandler.php
* RequestHandler->handleRequest(HTTPRequest)
Line 121 of RequestHandler.php
* RequestHandler->handleRequest(HTTPRequest)
Line 121 of RequestHandler.php
* RequestHandler->handleRequest(HTTPRequest)
Line 122 of Controller.php
* Controller->handleRequest(HTTPRequest)
Line 277 of Director.php
* Director::handleRequest(HTTPRequest,Session)
Line 121 of Director.php
* Director::direct(/admin/EditForm/field/EmailRecipients/AddForm)
Line 115 of main.php

Any ideas anyone?

Cheers
Aaron

Avatar
Double-A-Ron

Community Member, 604 Posts

27 April 2009 at 10:55am

I just tried another upgraded, with UserForms, on a different site using 2.2.2 and hosted on a completely different box.

Exact same errors.

Looks like the latest build (modules_userforms_trunk-r75129.zip) is borked. I'll post a bug report.

Aaron

Avatar
Double-A-Ron

Community Member, 604 Posts

27 April 2009 at 11:03am

Bug report posted. http://open.silverstripe.org/ticket/3931

Avatar
nostrad

Community Member, 25 Posts

27 April 2009 at 11:10pm

I am experiencing the exact same problem for my 2.3.1 site with the latest UserForms.

This is my error message:

[User Error] Object::__call() Method 'setCustomValidationMessage' not found in class 'DropdownField'
GET /jethro/contact-us/

Line 133 in /data/15/1/99/97/1751423/user/1892604/htdocs/jethro/sapphire/core/Object.php

How can you (SS) guys release code without testing it? You are causing endless frustration and agony for users.

Avatar
nostrad

Community Member, 25 Posts

27 April 2009 at 11:19pm

BTW, the latest UserForms download that Im using and with which the error is happening is :

modules_userforms_trunk-r75270.zip

Avatar
Double-A-Ron

Community Member, 604 Posts

28 April 2009 at 9:21am

Where did you get this from? The "Latest Trunk Build" on the official module page is r75257.

Avatar
micahsheets

Community Member, 165 Posts

30 April 2009 at 3:55am

Edited: 30/04/2009 10:49am

@Nostrad, You are using a "Trunk" version, therefore you are using unstable code. Use the release version for stability.

I am also having this same issue with the "Trunk" version where I get:

setCustomValidationMessage' not found in class 'TextField'

I may be way off but when I create a text field using the User Forms I exptected that it was using the EditableTextField class not TextField and that is why the setCustomValidation Method is missing.

I hope this gets fixed soon as I have a site that has to go live tomorrow that needs some custom forms and I don't have time to learn how to program them myself.

Note: I have found that the "Trunk" version of userforms works with the "Trunk" version of SS not version 2.3.1.