Skip to content

Commit

Permalink
Move translation call to own method on trait FormHelpers
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-lenz committed May 27, 2019
1 parent a0fe1fc commit c463c45
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/foreignField/traits/FormHelpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ public function getAttributeOptions($attribute) {
? $attributeOptions[$attribute]
: [];

$domain = $this->_field::TRANSLATION_DOMAIN;
foreach ($options as $key => $value) {
$options[$key] = Craft::t($domain, $value);
$options[$key] = $this->translate($value);
}

return $options;
Expand Down Expand Up @@ -74,4 +73,13 @@ public function isAttributeRequired($attribute) {

return false;
}

/**
* @param string $value
* @return string
*/
protected function translate($value) {
$domain = $this->_field::TRANSLATION_DOMAIN;
return Craft::t($domain, $value);
}
}

0 comments on commit c463c45

Please sign in to comment.