Hi, I have a news-section on my site and when I go to the updateview the characters displayed in title and textarea fields are in the wrong format, so I want to process the characters with:
In your model class, modify the returned value from the db to be your converted value. You can set the title field directly, or if you need to preserve it, you can use another property, like so:
var $convertedTitle;
public function afterFind() {
$this->convertedTitle = mb_convert_encoding($this->title,"UTF-8", "Windows-1252");
}
Then you can use it in your view directly using the convertedTitle attribute (or just title if you decide to overwrite it in afterFind() ).
If you do decide to use convertedTitle, then you also need to override beforeSave() to save the new title to the db. If you decide to just overwrite title then you don’t need this.
public function beforeSave() {
$this->title = $this->convertedTitle;
return parent::beforeSave();
}
Depending on what you’re doing, you may also need to convert back to Windows-1252 in beforeSave(), otherwise it will be stored as a utf-8 value.