开发者

How to make Zend_Form display special characters in text elements?

I am using a Zend_Form subclass to add and edit records in a database. The layout has iso-8859-1 encoding and charset. The table records use latin1_spanish_ci collation.

The form input text element doesn't display anything at all when the record contains开发者_运维技巧 special characters like accents. If there are no special characters the form input text element displays the record correctly. Curiously enough the special characters display correctly when they appear outside the text input field, for example inside an Html heading2 or a paragraph.

I have tried inserting the following in application.ini:

resources.db.params.charset=iso-8859-1  

but I get an error message:

SQLSTATE[42000] [1115] Unknown character set: 'iso-8859-1'  

I have also tried changing the db charset to utf8 in the same way. The form text element displays the string but I get strange characters instead of the original ones.

I have tried almost anything but I haven't solved the problem. It seems that text input elements generated with Zend_Form hate Latin characters.

Have you had the same problem?


I found this simple solution in a zf forum:
Add the following to your _initView function in bootstrap.php and forget about everything else:

$view->setEncoding('iso-8859-1');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜