What is the best method to convert the decimal/double values to database?
Example:
Form field: 1.200,50 To: 1200.50
I know that we can use replace and other functions, but i want know an automatic method from Yii because i need transform some values to can use to male calcs and store on database.
Maybe CFilterValidator and using your custom function that wraps your str_replace calls? BTW i think strtr() is faster if you’re only replacing single characters.
But to format a number to our locale we can use the "numberFormater", so dont have a "numberFormater" to format the number to PHP format or database format?
The afterFind function is obvious, you just pass the pattern you want to the format function of CNumberFormatter and you get the localized version of your pattern.
The beforeSave function was harder. I decided to first check if there even was a number to convert then compare the decimal symbols of the current locale and the source locale and if they are different then do a PHP strtr to replace the current locale group and decimal symbols with the source group and decimal symbols before saving.