Permalink
Browse files

ENHANCEMENT Removed UniqueField.js dependency to CMS-related statusMe…

…ssage() javascript class, and using jQuery even triggers instead

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@92540 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 0b25cb9 commit 28109df4381c2da9f361ef7275eb172bd21d7ff2 @chillu chillu committed Nov 21, 2009
Showing with 9 additions and 5 deletions.
  1. +1 −0 forms/UniqueTextField.php
  2. +8 −5 javascript/UniqueFields.js
@@ -25,6 +25,7 @@ function __construct($name, $restrictedField, $restrictedTable, $restrictedMessa
function Field() {
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
+ Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/jquery/jquery.js");
Requirements::javascript(SAPPHIRE_DIR . "/javascript/UniqueFields.js");
/*
View
@@ -6,12 +6,13 @@ UniqueFormField.prototype = {
if( this.restrictedValues[suggested] || suggested == null ) {
suggested = this.suggestNewValue();
- statusMessage(ss.i18n.sprintf(
+ var message = i18n.sprintf(
ss.i18n._t('UNIQUEFIELD.SUGGESTED', "Changed value to '%s' : %s"),
suggested,
this.restrictedMessage
- ));
- this.value = suggested;
+ );
+ jQuery(this).trigger('validate', {message: message, suggested: suggested});
+ this.value = suggested;
}
},
suggestNewValue: function() {
@@ -108,11 +109,13 @@ UniqueRestrictedTextField.prototype = {
message = this.charMessage;
suggested = this.suggestNewValue();
- statusMessage(ss.i18n.sprintf(
+ var message = ss.i18n.sprintf(
ss.i18n._t('UNIQUEFIELD.SUGGESTED', "Changed value to '%s' : %s"),
suggested,
message
- ));
+ );
+
+ jQuery(this).trigger('validate', {message: message, suggested: suggested});
}
this.value = suggested;

0 comments on commit 28109df

Please sign in to comment.