zendframework / zend-form

Form component from Zend Framework
BSD 3-Clause "New" or "Revised" License
69 stars 87 forks source link

Zend\Form\Element\Submit and i18n #113

Open adrianilie9 opened 8 years ago

adrianilie9 commented 8 years ago

The "value" attribute of a \Zend\Form\Element\Submit gets translated twice.

Take for example the code below:

$submit = new \Zend\Form\Element\Submit('Submit', array());
$submit->setAttribute('value', 'Sign in');

At this point, if i render the element, the "Sign in" value will get translated, all good. However, after the POST has been sent, in my controller i prepare to perform the validation:

$data = $this->params()->fromPost();
$form->setData($data);

After calling setData(), the already translated "Sign in" will try to get translated again.

This is generally not an issue, however in my implementation if a \Zend\I18n\Translator\Translator::EVENT_MISSING_TRANSLATION is triggered, the unknown string will be added to the PO language file, which kinda messes it up, because you now have strings from different languages into the same language file.

weierophinney commented 4 years ago

This repository has been closed and moved to laminas/laminas-form; a new issue has been opened at https://github.com/laminas/laminas-form/issues/25.