public function render(ElementInterface $element)
{
if (!$element instanceof CheckboxElement) {
throw new Exception\InvalidArgumentException(sprintf('%s requires that the element is of type Zend\\Form\\Element\\Checkbox', __METHOD__));
}
$name = $element->getName();
if (empty($name) && $name !== 0) {
throw new Exception\DomainException(sprintf('%s requires that the element has an assigned name; none discovered', __METHOD__));
}
$attributes = $element->getAttributes();
$attributes['name'] = $name;
$attributes['type'] = $this->getInputType();
$attributes['value'] = $element->getCheckedValue();
$closingBracket = $this->getInlineClosingBracket();
if ($element->isChecked()) {
$attributes['checked'] = 'checked';
}
if ($element->getAttribute('class') != 'input-checkbox') {
$rendered = sprintf('<input %s%s', $this->createAttributesString($attributes), $closingBracket);
} else {
if ($element->getAttribute('id') == '') {
$element->setAttribute('id', 'checkbox-' . uniqid());
}
unset($attributes['class']);
$rendered = sprintf('<span class="input-checkbox"><input %s%s<label for="%s"></label></span>', $this->createAttributesString($attributes), $closingBracket, $element->getAttribute('id'));
}
return $rendered;
}