Search code examples
zend-frameworkwebformszend-formzend-form-element

How can be form field names translated when they generate by Zend_Form?


How can be form field names translated when they generate by Zend_Form?

if we have:

<label>Phone</label>

in zend label can be translated by:

<label><?php echo $this->translate('Phone'); ?></label>

but when the label created by Zend_Form:

$phone = new Zend_Form_Element('phone');
$phone->setLabel('Phone');

How can be label translated?

Thanks


Solution

  • I suggest you read up on using I18n with Zend_Form : http://framework.zend.com/manual/en/zend.form.i18n.html

    But basically you have to pass your Zend_Translate instance to Zend_Form, by calling the setDefaultTranslator static method.