duandan4680 2012-11-21 17:54
浏览 20

使用带有特殊字符编码的Cakephp Forms

I'm starting to use cakephp and i still have some doubts. Precisely about the .ctp files. After research, i found they are template files used to phpcake to read php code. But what about the encoding. I tested this code in a file with "Utf-8 without bom" codification", but browsers still can't recognize letters like "ç" or "ã" contained in the following example:

<!-- File: /app/View/Posts/add.ctp -->

<h1>Add Post</h1>
<?php
echo $this->Form->create('Post');
echo $this->Form->input('Nome Produto');
echo $this->Form->input('Código Produto');
echo $this->Form->input('Versão');
echo $this->Form->input('Data');
//echo $this->Form->input('body', array('rows' => '3'));
echo $this->Form->end('Criar Ficha');
?>

There is some particular configuration i need to add to this ctp files to avoid this codification problems?

P.S. Problem solved. The Form->input was created wrong. Should have been:

echo $this->Form->input('cod_produto', array('label' => 'Código Produto:'));

since the first parameter is the name of the field in the bd. Thanks mark for all the help!

  • 写回答

1条回答 默认 最新

  • du7535 2012-11-21 18:06
    关注

    Try putting the following line into your default.ctp template file (or whatever template file your whole site is using). This should set the encoding of the whole site no matter which page you are on:

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    
    评论

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教