Skip to content

Commit

Permalink
type fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 4, 2021
1 parent 3753d36 commit 02ad720
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Forms/Controls/BaseControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,11 @@ public function getLabel(string|Stringable $caption = null): Html|string|null
$label = clone $this->label;
$label->for = $this->getHtmlId();
$caption ??= $this->caption;
$translator = $this->getForm()->getTranslator();
$label->setText($translator && !$caption instanceof Nette\HtmlStringable ? $translator->translate($caption) : $caption);
if (!$caption instanceof Nette\HtmlStringable) {
$translator = $this->getForm()->getTranslator();
$caption = $translator ? $translator->translate($caption) : (string) $caption;
}
$label->setText($caption);
return $label;
}

Expand Down

0 comments on commit 02ad720

Please sign in to comment.