`. * * ``` * * * ``` * * @see https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-form-radio */ final class RadioViewHelper extends AbstractFormFieldViewHelper { /** * @var string */ protected $tagName = 'input'; public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this ViewHelper', false, 'f3-form-error'); $this->registerArgument('checked', 'bool', 'Specifies that the input element should be preselected'); $this->registerArgument('value', 'string', 'Value of input tag. Required for radio buttons', true); } public function render(): string { $checked = $this->arguments['checked']; $this->tag->addAttribute('type', 'radio'); $nameAttribute = $this->getName(); $valueAttribute = $this->getValueAttribute(); $propertyValue = null; if ($this->hasMappingErrorOccurred()) { $propertyValue = $this->getLastSubmittedFormData(); } if ($checked === null && $propertyValue === null) { $propertyValue = $this->getPropertyValue(); $propertyValue = $this->convertToPlainValue($propertyValue); } if ($propertyValue !== null) { // no type-safe comparison by intention $checked = $propertyValue == $valueAttribute; } $this->registerFieldNameForFormTokenGeneration($nameAttribute); $this->tag->addAttribute('name', $nameAttribute); $this->tag->addAttribute('value', (string)$valueAttribute); if ($checked === true) { $this->tag->addAttribute('checked', 'checked'); } $this->setErrorClassAttribute(); return $this->tag->render(); } }