Neos\Media\ViewHelpers\Form\CheckboxViewHelper::render PHP Метод

render() публичный Метод

This is changed to use the actual provided value of the value attribute to support selecting object values.
public render ( boolean $checked = null, boolean $multiple = null ) : string
$checked boolean Specifies that the input element should be preselected
$multiple boolean Specifies whether this checkbox belongs to a multivalue (is part of a checkbox group)
Результат string
    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();
    }