Changeset 1480

Show
Ignore:
Timestamp:
10/28/2006 02:43:27 AM (2 years ago)
Author:
wei
Message:

Add TActiveCustomValidator to change ErrorMessage? on callbback.

Location:
trunk/framework/Web
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/framework/Web/Javascripts/js/compressed/validator.js

    r1467 r1480  
    1313{if(this.managers[formID]) 
    1414this.managers[formID].addSummary(validator);else 
    15 throw new Error("A validation manager for form '"+formID+"' needs to be created first.");return this.managers[formID];}});Prado.ValidationManager=Class.create();Prado.ValidationManager.prototype={validators:[],summaries:[],groups:[],options:{},initialize:function(options) 
     15throw new Error("A validation manager for form '"+formID+"' needs to be created first.");return this.managers[formID];},setErrorMessage:function(validatorID,message) 
     16{$H(Prado.Validation.managers).each(function(manager) 
     17{manager[1].validators.each(function(validator) 
     18{if(validator.options.ID==validatorID) 
     19{validator.options.ErrorMessage=message;$(validatorID).innerHTML=message;}});});}});Prado.ValidationManager=Class.create();Prado.ValidationManager.prototype={validators:[],summaries:[],groups:[],options:{},initialize:function(options) 
    1620{this.options=options;Prado.Validation.managers[options.FormID]=this;},validate:function(group,invoker) 
    1721{if(group) 
  • trunk/framework/Web/Javascripts/js/debug/validator.js

    r1467 r1480  
    141141                        throw new Error("A validation manager for form '"+formID+"' needs to be created first."); 
    142142                return this.managers[formID]; 
     143        }, 
     144 
     145        setErrorMessage : function(validatorID, message) 
     146        { 
     147                $H(Prado.Validation.managers).each(function(manager) 
     148                { 
     149                        manager[1].validators.each(function(validator) 
     150                        { 
     151                                if(validator.options.ID == validatorID) 
     152                                { 
     153                                        validator.options.ErrorMessage = message; 
     154                                        $(validatorID).innerHTML = message; 
     155                                } 
     156                        }); 
     157                }); 
    143158        } 
    144159}); 
  • trunk/framework/Web/Javascripts/prado/validation3.js

    r1467 r1480  
    141141                        throw new Error("A validation manager for form '"+formID+"' needs to be created first."); 
    142142                return this.managers[formID]; 
     143        }, 
     144 
     145        setErrorMessage : function(validatorID, message) 
     146        { 
     147                $H(Prado.Validation.managers).each(function(manager) 
     148                { 
     149                        manager[1].validators.each(function(validator) 
     150                        { 
     151                                if(validator.options.ID == validatorID) 
     152                                { 
     153                                        validator.options.ErrorMessage = message; 
     154                                        $(validatorID).innerHTML = message; 
     155                                } 
     156                        }); 
     157                }); 
    143158        } 
    144159}); 
  • trunk/framework/Web/UI/ActiveControls/TActiveCustomValidator.php

    r1467 r1480  
    126126 
    127127        /** 
     128         * Sets the text for the error message. Updates client-side erorr message. 
     129         * @param string the error message 
     130         */ 
     131                public function setErrorMessage($value) 
     132        { 
     133                parent::setErrorMessage($value); 
     134                if($this->getActiveControl()->canUpdateClientSide()) 
     135                { 
     136                        $client = $this->getPage()->getCallbackClient(); 
     137                        $func = 'Prado.Validation.setErrorMessage'; 
     138                        $client->callClientFunction($func, array($this, $value)); 
     139                } 
     140        } 
     141 
     142        /** 
    128143         * Register the javascript for the active custom validator. 
    129144         */