public function render($checked = null, $multiple = null)
{
$this->tag->addAttribute('type', 'checkbox');
$valueAttribute = $this->getValueAttribute(true);
$propertyValue = null;
if ($this->hasMappingErrorOccurred()) {
$propertyValue = $this->getLastSubmittedFormData();
}
if ($checked === null && $propertyValue === null) {
$propertyValue = $this->getPropertyValue();
}
if ($propertyValue instanceof \Traversable) {
$propertyValue = iterator_to_array($propertyValue);
}
if (is_array($propertyValue)) {
if ($checked === null) {
$checked = in_array($valueAttribute, $propertyValue, true);
}
$this->arguments['multiple'] = true;
} elseif (!$multiple && $propertyValue !== null) {
$checked = (bool) $propertyValue === (bool) $valueAttribute;
}
$nameAttribute = $this->getName();
if (isset($this->arguments['multiple']) && $this->arguments['multiple'] === true) {
$nameAttribute .= '[]';
}
$this->registerFieldNameForFormTokenGeneration($nameAttribute);
$this->tag->addAttribute('name', $nameAttribute);
$this->tag->addAttribute('value', $valueAttribute);
if ($checked === true) {
$this->tag->addAttribute('checked', 'checked');
}
$this->addAdditionalIdentityPropertiesIfNeeded();
$this->setErrorClassAttribute();
$this->renderHiddenFieldForEmptyValue();
return $this->tag->render();
}