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