gpt4 book ai didi

php - Zend_Form 占位符翻译

转载 作者:可可西里 更新时间:2023-10-31 22:58:08 25 4
gpt4 key购买 nike

我有一个带有 Zend_Form 的 Zend 应用程序,它应该使用 HTML5 placeholder 属性而不是标签,like done here .

class Application_Form_Usereditprofile extends Zend_Form
{
public function init()
{
[...]
$this->addElement('text', 'FirstName', array(
'filters' => [...],
'validators' => [...],
'placeholder'=> 'user_editprofile_firstname', // string I want to translate
));
[...]
}
}

我初始化了 Zend_Translate,所以它应该默认翻译我的表单。这适用于标签。但是,占位符将按原样使用,无需翻译。

如何翻译占位符字符串?

最佳答案

您可以像这样访问翻译助手

'placeholder'=> $this->getView()->translate('user_editprofile_firstname),

顺便说一句。 plceholder 属性不能替代 label

来自spec :

The placeholder attribute should not be used as an alternative to a label.

关于php - Zend_Form 占位符翻译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8368726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com