You are not logged in.
Pages: 1
Hi,
I have been doing apps using zf, and never had a problem with charsets and zend framework, usually i use the default latin1, including in the database.
As far as i can tell latin1 supports all the chars we use in portuguese.
Problem is that now, every time i try to populate a Zend form with database data, and that data contains special chars like ç or é or ã, the value is not rendered.
If i get the values form the database, pass them to the view and echo that value, it gets outputed ok, if i pass it to a zend from it dont get outputed at all it renders something like value=""
I tryed to change the app, includding the view and database to utf8 but the problem still the same.
I have been asking this to friends and at the #zftalk channel in the IRC but so far no solution.
I created a small simple ZF project to illustrate the problem, the project has:
1 database with 1 table.
1 form
1 controller with 1 action
1 model and 1 bdtable model
1 view
Its simple and illustrate's the problem i'm having, anyone can access it as www.gmporto.com/UTFtest.zip
I need to solve this problem, but i need to understand what the problem is and what is causing it. So if anyone can help me out, i would be gratefull, but if you solve it, please tell me what i've done wrong and how you fixed it so i can learn as well.
Thank you every one in advance.
Offline
Hi Miguel
I had the same problem.
In the controller:
public function preDispatch()
{
$this->view->setEscape('stripslashes');
}
and the problem is solved.
Basicaly you're telling the View to escape the values from the DB.
Last edited by rpsimao (2010-05-15 22:19:35)
Offline
Hi rpsimao,
Thanks a lot, that did the trick.
But instead of adding a predispatch function to each controller and since i initialize de viewRenderer in the main bootstrap i just made $view->setEscape('stripslashes'); in the bootstrap that way i don't have to hack every controller.
It is strange do, i've build around 4/5 costum cms's with ZF all for sites in portuguese and never had this problem.
I wonder why this happens now and didn't before, since i used code from the other apps.
Well thanks a lot.
I will be around so if you need any help just shoot. Of course the rest of the forum members as well.
Last edited by miguelp (2010-05-15 23:53:36)
Offline
Hi Miguel
I didn't put the "escape" in the Bootstrap because I found that this was a Zend_Form problem. I don't recall how I found the solution, I just dig the Zend_Form code.
Since I don't know why the hell Zend_Form do it, I prefer to fine grain the Controller that it needs it than set it globally.
I do recall that it only happen once in a app. The only difference for that app was the MySQL version that was v4.
Offline
Pages: 1