Skip to content

Commit d260d62

Browse files
committed
IControl: removed translate(), it is just part of BaseControl
1 parent 4473513 commit d260d62

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

src/Forms/IControl.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,4 @@ function getErrors();
4444
*/
4545
function isOmitted();
4646

47-
/**
48-
* Returns translated string.
49-
* @param string
50-
* @param int plural count
51-
* @return string
52-
*/
53-
function translate($s, $count = NULL);
54-
5547
}

src/Forms/Rendering/DefaultFormRenderer.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,10 @@ public function renderPairMulti(array $controls)
381381
$description = ' ' . $control->getOption('description');
382382

383383
} elseif (is_string($description)) {
384-
$description = ' ' . $this->getWrapper('control description')->setText($control->translate($description));
384+
if ($control instanceof Nette\Forms\Controls\BaseControl) {
385+
$description = $control->translate($description);
386+
}
387+
$description = ' ' . $this->getWrapper('control description')->setText($description);
385388

386389
} else {
387390
$description = '';
@@ -437,7 +440,10 @@ public function renderControl(Nette\Forms\IControl $control)
437440
$description = ' ' . $description;
438441

439442
} elseif (is_string($description)) {
440-
$description = ' ' . $this->getWrapper('control description')->setText($control->translate($description));
443+
if ($control instanceof Nette\Forms\Controls\BaseControl) {
444+
$description = $control->translate($description);
445+
}
446+
$description = ' ' . $this->getWrapper('control description')->setText($description);
441447

442448
} else {
443449
$description = '';

src/Forms/Validator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static function formatMessage(Rule $rule, $withValue = TRUE)
6767
static $i = -1;
6868
switch ($m[1]) {
6969
case 'name': return $rule->control->getName();
70-
case 'label': return $rule->control->translate($rule->control->caption);
70+
case 'label': return $rule->control instanceof Controls\BaseControl ? $rule->control->translate($rule->control->caption) : NULL;
7171
case 'value': return $withValue ? $rule->control->getValue() : $m[0];
7272
default:
7373
$args = is_array($rule->arg) ? $rule->arg : [$rule->arg];
@@ -135,7 +135,7 @@ public static function validateBlank(IControl $control)
135135
* Is control valid?
136136
* @return bool
137137
*/
138-
public static function validateValid(IControl $control)
138+
public static function validateValid(Controls\BaseControl $control)
139139
{
140140
return $control->getRules()->validate();
141141
}

0 commit comments

Comments
 (0)