Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Stop FormRow from translating the label twice #20

Merged
merged 5 commits into from
Apr 7, 2016

Conversation

terpfear
Copy link
Contributor

Prevents the label from being translated and processed multiple times. When $labelHelper is invoked with only one argument, it will translate and process the label, and not add anything extra. There is no need for this extra work in FormRow, which has already done this translation. This small change also allows for a more uniform code path when the element has an id and when it does not.

Prevents the label from being translated and processed multiple times. When $labelHelper is invoked with only one argument, it will translate and process the label, and not add anything extra. There is no need for this extra work in FormRow, which has already done this translation. This small change also allows for a more uniform code path when the element has an id and when it does not.
@terpfear
Copy link
Contributor Author

I made a wrong assumption,I will update this pull request when it is fixed.

Made a small error in my first commit that put the </label> at the end of the element every time.
@terpfear
Copy link
Contributor Author

I fixed the error in my patch. Let me know what I can do to help this pull request pass all tests. It is currently skipping 4 tests in travis-ci.

@terpfear
Copy link
Contributor Author

I didn't realize it was failing due to extra white space, patch is fixed and is now passing tests.

@Maks3w
Copy link
Member

Maks3w commented Oct 22, 2015

Need unit test verifying the bug is fixed

@Maks3w Maks3w added the Test label Oct 22, 2015
Translator should only be called once on the element label. These tests make sure this is true whether or not the element has a label.
@terpfear
Copy link
Contributor Author

Tests have been added. Let me know if I need to do more or correct anything.

$element = new Element('foo');
$element->setLabel('The value for foo:');

$mockTranslator = $this->getMock('Zend\I18n\Translator\Translator');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use PHP 5.5 ::class and TranslatorInterface

@weierophinney weierophinney added this to the 2.7.1 milestone Apr 7, 2016
@weierophinney weierophinney self-assigned this Apr 7, 2016
@weierophinney weierophinney merged commit ec3c63f into zendframework:master Apr 7, 2016
weierophinney added a commit that referenced this pull request Apr 7, 2016
Stop FormRow from translating the label twice
weierophinney added a commit that referenced this pull request Apr 7, 2016
weierophinney added a commit that referenced this pull request Apr 7, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants