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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

javascript validation error in CMS


Go to End


3 Posts   2343 Views

Avatar
martimiz

Forum Moderator, 1391 Posts

8 February 2009 at 8:26am

Edited: 08/02/2009 8:51am

I get this javascript error every so often in Firefox 3.0.6 when updating a page (new pagetype) in the CMS (2.3rc3):

$("Form_EditForm").validateEmailField is not a function

(I have an emailfield in the CMS for this page - should I not use it here?). After that the CMS hangs on saving the page and it won't save any other pages until I restart the browser. It started to occur after I added a TableField to the CMSFields of the Page. It seems to happen mostly after I update the Page Model. Could all be a coincidence though. Is this a known bug?
.
[edit] Found that it happens in IE as well...
.
Also I always get this on initial startup (showing the admin login):

jQuery is not defined  http://<mysite>/Security/Login

Avatar
Webbower

Community Member, 10 Posts

3 March 2009 at 5:49pm

I get the same problem. If I switch the EmailField in the Admin panel for the page type in question, to a TextField and reload the page with ?flush=1, the form works. But that should be the way it's supposed to work. I found the source of the code, but I don't know how to work with the JS library being used. The

validateEmailField
function is being written with the Behaviour JS library and probably using Prototype and I'm a jQuery person. The problem is in the
sapphire/forms/EmailField.php
file.

Avatar
ilyabr

Community Member, 2 Posts

29 April 2009 at 6:17am

I had the same problem. After investigating a bit I figured out that I have it only when we have more than one form on a page (with email fields present in more than one as well). It seems to me that there is a bug in Silverstripe (I use 2.3.1):
line 30 in EmailField.php stores generated javascript in a hash in order to be dumped on the page later; unfortunately it is being stored under constant key (func_validateEmailField), therefore the last form processed overwrites the previous one, and the required javascript function is never created. I got around by adding a unique string to the key (form name), like this:

Requirements::customScript($jsFunc, 'func_validateEmailField' .'_' . $formID);

I'll try to submit a bug.