formRow View Helper does not recognize / utilize injected translator service #2551

zfbot opened this Issue Sep 28, 2012 · 6 comments


None yet

4 participants

zfbot commented Sep 28, 2012

Jira Information

Original Issue:ZF2-516
Issue Type:Bug
Reporter:Michael Romer


The FormRow-Helper seems not to use a translator service present for the label portion:

            'name' => 'username',
            'attributes' => array(
                'type'  => 'text',
            'options' => array(
                'label' => 'username',
public function onBootstrap($e)
echo $this->formRow($this->form->get('username')); 
echo $this->formLabel($this->form->get('username'));
Output incorrect: "username", even if translation available
Output correct: "Benutzername" (DE translation of "username")
zfbot commented Sep 28, 2012

(Originally posted by: froschdesign on 09/04/12)

Code tags added.

zfbot commented Sep 28, 2012

(Originally posted by: cgmartin on 09/05/12)

The FormLabel's translation functionality is covered with a unit test (and currently passing):

For the translator to automatically attach to the view helpers, the translator should be in the service locator. Example via config from the skeleton application:

Here is the code that pulls it out of the service locator and attaches it to the view helpers (including FormLabel):

Some things to check:

  • Confirm that the translator is set on the FormLabel helper: var_dump($this->formLabel()->getTranslator())
  • Do the translation text domains match?: var_dump($this->formLabel()->getTranslatorTextDomain())
  • Does the translation key match and exist in your DE translation file?

EDIT: Apologies, I just noticed your output of both FormRow and FormLabel together... I will set up a test here and take a look see. Thanks!

zfbot commented Sep 28, 2012

(Originally posted by: cgmartin on 09/05/12)

FormRow was not translating the label. Fixed in this PR:

zfbot commented Sep 28, 2012

This issue was ported from the ZF2 Jira Issue Tracker at

Known GitHub users mentioned in the original message or comment:
@weierophinney, @froschdesign, @cgmartin


@weierophinney @michael-romer i think this can be closed as well. Translation for labels in formRow works.

@Maks3w Maks3w closed this Mar 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment