970_90

Tuesday, 6 September 2011

cakephp multilingual validation

Cakephp Multilingual  Validation



Website which is multilingual, messages will be also multilingual. To set the different error message follow the below some simple steps.

Paste following code in app_model.php
Code:
        function invalidate($field, $value = null) { 

        if (!is_array($this->validationErrors)) { 

            $this->validationErrors = array(); 

        } 

        if(empty($value)) { 

            $value = true; 

        } 

        $this->validationErrors[$field] = __($value,  true);         

    }

field collation in database must be "utf8_unicode_ci"  


2 comments:

  1. After 3-4 hrs of google search, finally this work worked fine for me.
    Thanks a lot

    ReplyDelete