I have a Zend application with a Zend_Form, which should use the HTML5 placeholder
attribute instead of labels, 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
));
[...]
}
}
I initialized Zend_Translate so it should translate my forms by default. This works fine with labels. However, the placeholder gets used as it is, without being translated.
How can I translate the placeholder strings?
You can access the the translate helper like this
'placeholder'=> $this->getView()->translate('user_editprofile_firstname),
btw. the plceholder
attribute is not a substitution for the label
.
From the spec:
The placeholder attribute should not be used as an alternative to a label.