Skip to content

Commit 02ad720

Browse files
committed
type fix
1 parent 3753d36 commit 02ad720

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Forms/Controls/BaseControl.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,11 @@ public function getLabel(string|Stringable $caption = null): Html|string|null
253253
$label = clone $this->label;
254254
$label->for = $this->getHtmlId();
255255
$caption ??= $this->caption;
256-
$translator = $this->getForm()->getTranslator();
257-
$label->setText($translator && !$caption instanceof Nette\HtmlStringable ? $translator->translate($caption) : $caption);
256+
if (!$caption instanceof Nette\HtmlStringable) {
257+
$translator = $this->getForm()->getTranslator();
258+
$caption = $translator ? $translator->translate($caption) : (string) $caption;
259+
}
260+
$label->setText($caption);
258261
return $label;
259262
}
260263

0 commit comments

Comments
 (0)