This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
FormButton $buttonContent parameter is now translated #7184
Closed
Victory
wants to merge
7
commits into
zendframework:master
from
Victory:form-button-translate-content-param
Closed
FormButton $buttonContent parameter is now translated #7184
Victory
wants to merge
7
commits into
zendframework:master
from
Victory:form-button-translate-content-param
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -91,6 +91,12 @@ public function render(ElementInterface $element, $buttonContent = null) | |||
$buttonContent, $this->getTranslatorTextDomain() | |||
); | |||
} | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the extra else
. You can simply move the first if
:
/**
* Render a form <button> element from the provided $element,
* using content from $buttonContent or the element's "label" attribute
*
* @param ElementInterface $element
* @param null|string $buttonContent
* @throws Exception\DomainException
* @return string
*/
public function render(ElementInterface $element, $buttonContent = null)
{
$openTag = $this->openTag($element);
if (null === $buttonContent) {
$buttonContent = $element->getLabel();
if (null === $buttonContent) {
throw new Exception\DomainException(sprintf(
'%s expects either button content as the second argument, ' .
'or that the element provided has a label value; neither found',
__METHOD__
));
}
}
if (null !== ($translator = $this->getTranslator())) {
$buttonContent = $translator->translate(
$buttonContent, $this->getTranslatorTextDomain()
);
}
if (! $element instanceof LabelAwareInterface || ! $element->getLabelOption('disable_html_escape')) {
$escapeHtmlHelper = $this->getEscapeHtmlHelper();
$buttonContent = $escapeHtmlHelper($buttonContent);
}
return $openTag . $buttonContent . $this->closeTag();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion, i have added the changes and pushed.
…onContent as a parameter
…ory/zf2 into form-button-translate-content-param Conflicts: library/Zend/Form/View/Helper/FormButton.php
There seems to be some unrelated failing tests in "ZendTest\Cache\Storage\Adapter\DbaInifileTest" on travis. The test in this pull request passes. |
weierophinney
added a commit
that referenced
this pull request
Feb 25, 2015
…aram FormButton $buttonContent parameter is now translated
weierophinney
added a commit
that referenced
this pull request
Feb 25, 2015
Merged to develop for release with 2.4. |
thanks as always @weierophinney ! |
# for free
to subscribe to this conversation on GitHub.
Already have an account?
#.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In master if you pass in a
$buttonContent
parameter toZend\Form\View\Helper\FormButton
the$buttonContent
is not translated.Zend\Form\View\Helper\FormButton->_invoke($element, "translate me")
This pull requests creates a test to show the error and a fix to this issue.