Neos\FluidAdaptor\ViewHelpers\Form\RadioViewHelper::render PHP Method

render() public method

Renders the checkbox.
public render ( boolean $checked = null ) : string
$checked boolean Specifies that the input element should be preselected
return string
    public function render($checked = null)
    {
        $this->tag->addAttribute('type', 'radio');
        $nameAttribute = $this->getName();
        $valueAttribute = $this->getValueAttribute(true);
        $propertyValue = null;
        if ($this->hasMappingErrorOccurred()) {
            $propertyValue = $this->getLastSubmittedFormData();
        }
        if ($checked === null && $propertyValue === null) {
            $propertyValue = $this->getPropertyValue();
        }
        if ($propertyValue !== null) {
            // no type-safe comparison by intention
            $checked = $propertyValue == $valueAttribute;
        }
        $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();
        return $this->tag->render();
    }

Usage Example

 /**
  * @test
  */
 public function renderCallsSetErrorClassAttribute()
 {
     $this->viewHelper->expects($this->once())->method('setErrorClassAttribute');
     $this->viewHelper->render();
 }