diff --git a/src/Forms/Helpers.php b/src/Forms/Helpers.php
index 55d701076..fc8973ec4 100644
--- a/src/Forms/Helpers.php
+++ b/src/Forms/Helpers.php
@@ -152,7 +152,7 @@ public static function createInputList(array $items, array $inputAttrs = null, a
$res .= ($res === '' && $wrapperEnd === '' ? '' : $wrapper)
. $labelTag . $label->attributes() . '>'
. $inputTag . $input->attributes() . (Html::$xhtml ? ' />' : '>')
- . ($caption instanceof Nette\Utils\IHtmlString ? $caption : htmlspecialchars($caption, ENT_NOQUOTES, 'UTF-8'))
+ . ($caption instanceof Nette\Utils\IHtmlString ? $caption : htmlspecialchars((string) $caption, ENT_NOQUOTES, 'UTF-8'))
. ''
. $wrapperEnd;
}
diff --git a/tests/Forms/Helpers.createInputList.phpt b/tests/Forms/Helpers.createInputList.phpt
index 84ad0116a..e9f08a674 100644
--- a/tests/Forms/Helpers.createInputList.phpt
+++ b/tests/Forms/Helpers.createInputList.phpt
@@ -25,6 +25,11 @@ test(function () {
Helpers::createInputList(['a'])
);
+ Assert::same(
+ '',
+ Helpers::createInputList([1])
+ );
+
Assert::same(
'',
Helpers::createInputList(