---
title: "Form.radio ViewHelper <f:form.radio>"
manual: "Fluid ViewHelper Reference"
version: "13.4"
permalink: "https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-form-radio@13.4"
source: "Global/Form/Radio.rst"
modified: "2026-09-15T08:12:09+00:00"
---

# Form.radio ViewHelper `<f:form.radio>`

ViewHelper which renders a simple radio button `<input type="radio">`.

Go to the source code of this ViewHelper: [Form\\RadioViewHelper.php (GitHub)](https://github.com/TYPO3/typo3/blob/main/typo3/sysext/fluid/Classes/ViewHelpers/Form/RadioViewHelper.php).

> [!TIP]
> When using multiple related radio buttons, wrap them
> in a `<fieldset>` with a `<legend>`, which  helps screen readers understand
> the purpose of the group and improves overall accessibility. It also gives
> your form better semantic structure.

**Table of content**

-   [Basic yes/no radio buttons tied to an action argument](https://docs.typo3.org/permalink/t3viewhelper:basic-yes-no-radio-buttons-tied-to-an-action-argument@13.4)
-   [Property mapping - Radio buttons bound to a model](https://docs.typo3.org/permalink/t3viewhelper:property-mapping-radio-buttons-bound-to-a-model@13.4)
-   [Radio buttons with options from an array or query result](https://docs.typo3.org/permalink/t3viewhelper:radio-buttons-with-options-from-an-array-or-query-result@13.4)
-   [Multiple radio button groups](https://docs.typo3.org/permalink/t3viewhelper:multiple-radio-button-groups@13.4)
-   [Arguments of the form radio ViewHelper](https://docs.typo3.org/permalink/t3viewhelper:arguments-of-the-form-radio-viewhelper@13.4)

## Basic yes/no radio buttons tied to an action argument

The following shows two radio buttons, the one labeled "No" is preselected.

**Fluid**

**packages/my_extension/Resources/Private/Templates/Comment/Newsletter.html**

```html
<f:form action="orderNewsletter" method="post">
    <fieldset>
        <legend>Would you like to order the newsletter?</legend>
        <f:form.radio name="orderNewsletter" id="orderNewsletterYes" value="1"/>
        <label for="orderNewsletter">Yes</label><br>
        <f:form.radio name="orderNewsletter" id="orderNewsletterNo" value="0" checked="1"/>
        <label for="orderNewsletterNo">No</label><br>
    </fieldset>
    <f:form.submit value="Submit"/>
</f:form>

```

**Controller**

The controller action can then look like this:

**packages/my_extension/Classes/Controller/NewsletterController.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Controller;

use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

class NewsletterController extends ActionController
{
  public function orderNewsletterAction(
    bool $orderNewsletter,
  ): ResponseInterface {
    if ($orderNewsletter) {
      // TODO: Newsletter ordering
    }
    return $this->htmlResponse();
  }
}

```

> [!TIP]
> You could ask the same question with a
> [Single optional checkbox](https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-form-checkbox-example@13.4).
> The main difference is, when you have a preselected radio button, the radio
> button group cannot be disabled again, therefore the parameter is always
> supplied to the action.

## Property mapping - Radio buttons bound to a model

The radio buttons from this example look the same as those from the previous
example, however an object of type `User` is now provided as parameter for
the Extbase action.

**Fluid**

**packages/my_extension/Resources/Private/Templates/Newsletter/SomeForm.html**

```html
<f:form action="orderNewsletter" method="post" object="user" objectName="user">
    <fieldset>
        <legend>Would you like to order the newsletter?</legend>
        <f:form.radio property="orderNewsletter" id="orderNewsletterYes" value="1"/>
        <label for="orderNewsletter">Yes</label><br>
        <f:form.radio name="orderNewsletter" id="orderNewsletterNo" value="0" checked="1"/>
        <label for="orderNewsletterNo">No</label><br>
    </fieldset>
    <f:form.submit value="Submit"/>
</f:form>

```

**Controller**

Then the controller action can look like this:

**packages/my_extension/Classes/Controller/NewsletterController.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Controller;

use MyVendor\MyExtension\Domain\Model\User;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

class NewsletterController extends ActionController
{
  public function orderNewsletterAction(
    User $user,
  ): ResponseInterface {
    if ($user->isOrderNewsletter()) {
      // TODO: Newsletter ordering
    }
    return $this->htmlResponse();
  }
}

```

**Model**

**packages/my_extension/Classes/Domain/Model/User.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Domain\Model;

use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;

class User extends AbstractEntity
{
  protected bool $orderNewsletter = false;

  public function isOrderNewsletter(): bool
  {
    return $this->orderNewsletter;
  }

  public function setOrderNewsletter(bool $orderNewsletter): void
  {
    $this->orderNewsletter = $orderNewsletter;
  }

}

```

## Radio buttons with options from an array or query result

The form radio ViewHelper does not supply an argument that creates it from
an array as you might have seen for the form select ViewHelper
([Select field for selecting (persisted) models](https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-form-select-usage-models@13.4)).

You can however just use the [For ViewHelper \<f:for>](https://docs.typo3.org/permalink/t3viewhelper:typo3fluid-fluid-for@13.4)
to iterate your items and display them one by one. If you use the objects uid
for the key, the radio button can be matched to the model in use.

**Fluid**

The Fluid template can be left unchanged even though we are dealing with a
different data source:

**packages/my_extension/Resources/Private/Templates/User/PaymentForm.html**

```html
<f:form action="selectPayment">
    <f:form.select name="payment" options="{paymentOptions}" value="{myPayment}" />
    <f:form.submit value="Submit"/>
</f:form>

```

**Model**

**packages/my_extension/Classes/Domain/Model/PaymentMethod.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Domain\Model;

use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;

class PaymentMethod extends AbstractEntity implements \Stringable
{
  protected string $title;
  protected string $paymentIdentifier;

  // Getters and setters

  // If the model implement the __toString() method
  // The result of that method is displayed in the select form
  public function __toString(): string
  {
    return $this->title;
  }
}

```

**Controller**

In the controller we can get all payment methods from the
[Repository](https://docs.typo3.org/m/typo3/reference-coreapi/13.4/en-us/ExtensionArchitecture/Extbase/Reference/Domain/Repository/Index.html#extbase-repository)
now and pass it to the view as variable:

**packages/my_extension/Classes/Controller/UserController.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Controller;

use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

class UserController extends ActionController
{
  public function __construct(
    protected readonly PaymentMethodRepository $paymentMethodRepository,
  ) {}

  public function paymentFormAction(): ResponseInterface
  {
    $paymentOptions = $this->paymentMethodRepository->findAll();
    $this->view->assign('paymentOptions', $paymentOptions);
    $this->view->assign('myPayment', 'visa');
    return $this->htmlResponse();
  }
  public function selectPaymentAction(PaymentMethod $payment): ResponseInterface
  {
    // do something
    return $this->redirect('show');
  }
}

```

> [!TIP]
> You can use the same model and controller as with
> [Select field for selecting (persisted) models](https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-form-select-usage-models@13.4).
>
> The integrator can choose to use a radio button or select element without
> that the backend has to be changed.

## Multiple radio button groups

Only one radio button per group can be checked at a time. Each group has the
same [name](https://docs.typo3.org/permalink/t3viewhelper:viewhelper-argument-typo3-cms-fluid-viewhelpers-form-radioviewhelper-name@13.4)
or [property](https://docs.typo3.org/permalink/t3viewhelper:viewhelper-argument-typo3-cms-fluid-viewhelpers-form-radioviewhelper-property@13.4).

> [!TIP]
> Each group of related radio buttons should be wrapped in its own
> `<fieldset>` with a `<legend>` to describe the purpose of the group.
>
> This ensures that screen readers and other assistive technologies can
> correctly interpret the relationship between the options. It also improves
> the semantic structure and visual clarity of your form.

## Arguments of the form radio ViewHelper

> **Allows arbitrary arguments**
>
> This ViewHelper allows you to pass arbitrary arguments not defined below
> directly to the HTML tag created. This includes custom `data-` arguments.

-   **additionalAttributes**

    -   *Type:* array

    Additional tag attributes. They will be added directly to the resulting HTML tag.

-   **aria**

    -   *Type:* array

    Additional aria-\* attributes. They will each be added with a "aria-" prefix.

-   **checked**

    -   *Type:* bool

    Specifies that the input element should be preselected

-   **data**

    -   *Type:* array

    Additional data-\* attributes. They will each be added with a "data-" prefix.

-   **errorClass**

    -   *Type:* string
    -   *Default:* 'f3-form-error'

    CSS class to set if there are errors for this ViewHelper

-   **name**

    -   *Type:* string

    Name of input tag

-   **property**

    -   *Type:* string

    Name of Object Property. If used in conjunction with \<f:form object="...">, the "name" property will be ignored, while "value" can be used to specify a default field value instead of the object property value.

-   **value**

    -   *Type:* string
    -   *Required:* true

    Value of input tag. Required for radio buttons
