---
title: "Form.countrySelect ViewHelper <f:form.countrySelect>"
manual: "Fluid ViewHelper Reference"
version: "main"
permalink: "https://docs.typo3.org/permalink/t3viewhelper:typo3-fluid-form-countryselect@main"
source: "Global/Form/CountrySelect.rst"
rendered: "2026-09-27T06:54:49+00:00"
---

# Form.countrySelect ViewHelper `<f:form.countrySelect>` {#typo3-fluid-form-countryselect}

ViewHelper which renders a `<select>` tag with all or specific countries as options.

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

## A basic country selector bound to an action argument {#typo3-fluid-form-countryselect-example}

For example a very simplified search form could look like this:

**Fluid**

**packages/my_extension/Resources/Private/Templates/User/SelectCountry.fluid.html**

```html
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
      data-namespace-typo3-fluid="true">
<f:form action="saveCountry">
    <f:form.countrySelect name="country" value="{defaultCountry}"/>
    <f:form.submit value="Submit"/>
</f:form>
</html>

```

**Controller**

The [Extbase controller](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/Extbase/Controller/Index.html#extbase-controller)
action could for example look like this:

**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
{
  /**
   * @param string $country ISO 2 country code ("BE", "FR", "US", ...)
   */
  public function createAction(string $country): ResponseInterface
  {
    return $this->redirect('show');
  }
}

```

## Prioritize countries {#typo3-fluid-form-countryselect-example-prioritizedcountries}

Define a list of countries which should be listed as first options in the
form element by setting
[prioritizedCountries](https://docs.typo3.org/permalink/t3viewhelper:viewhelper-argument-typo3-cms-fluid-viewhelpers-form-countryselectviewhelper-prioritizedcountries@main):

**packages/my_extension/Resources/Private/Templates/User/SelectCountry.fluid.html**

```html
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
      data-namespace-typo3-fluid="true">
<f:form action="saveCountry">
    <f:form.countrySelect
        name="country"
        value="AT"
        prioritizedCountries="{0: 'DE', 1: 'AT', 2: 'CH'}"
    />
    <f:form.submit value="Submit"/>
</f:form>
</html>

```

Additionally, Austria is pre-selected.

## Display another language {#typo3-fluid-form-countryselect-example-optionlabelfield}

A combination of [optionLabelField](https://docs.typo3.org/permalink/t3viewhelper:viewhelper-argument-typo3-cms-fluid-viewhelpers-form-countryselectviewhelper-optionlabelfield@main)
and [alternativeLanguage](https://docs.typo3.org/permalink/t3viewhelper:viewhelper-argument-typo3-cms-fluid-viewhelpers-form-countryselectviewhelper-alternativelanguage@main)
is possible. For
instance, if you want to show the localized official names but not in your
default language but in French. You can achieve this by using the following
combination:

**packages/my_extension/Resources/Private/Templates/User/SelectCountry.fluid.html**

```html
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
      data-namespace-typo3-fluid="true">
<f:form action="saveCountry">
    <f:form.countrySelect
        name="country"
        optionLabelField="localizedOfficialName"
        alternativeLanguage="fr"
        sortByOptionLabel="true"
    />
    <f:form.submit value="Submit"/>
</f:form>
</html>

```

## Bind the country selector to an Extbase model {#typo3-fluid-form-countryselect-example-property}

You can also use the [property](https://docs.typo3.org/permalink/t3viewhelper:viewhelper-argument-typo3-cms-fluid-viewhelpers-form-countryselectviewhelper-property@main)
attribute if you have bound an object to the form.

**Fluid**

**packages/my_extension/Resources/Private/Templates/User/SelectCountry.fluid.html**

```html
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
      data-namespace-typo3-fluid="true">
<f:form action="saveCountry" object="{user}" name="user">
    <f:form.countrySelect property="country"/>
    <f:form.submit value="Submit"/>
</f:form>
</html>

```

**Model**

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

```php
<?php

namespace Vendor\Extension\Domain\Model;

use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;

class User extends AbstractEntity
{
  // The country in ISO 2 code
  protected $country = '';

  // Getter and setter
}

```

## Arguments of f:form.countrySelect {#typo3-fluid-form-countryselect-arguments}

> **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.

-   **alternativeLanguage**

    -   *Type:* string

    If specified, the country list will be shown in the given language.

-   **aria**

    -   *Type:* array

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

-   **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

-   **excludeCountries**

    -   *Type:* array
    -   *Default:* array (
    )

    Array with country codes that should not be shown.

-   **multiple**

    -   *Type:* boolean
    -   *Default:* false

    If set multiple options may be selected.

-   **name**

    -   *Type:* string

    Name of input tag

-   **onlyCountries**

    -   *Type:* array
    -   *Default:* array (
    )

    If set, only the country codes in the list are rendered.

-   **optionLabelField**

    -   *Type:* string
    -   *Default:* 'localizedName'

    If specified, will call the appropriate getter on each object to determine the label. Use "name", "localizedName", "officialName" or "localizedOfficialName"

-   **prependOptionLabel**

    -   *Type:* string

    If specified, will provide an option at first position with the specified label.

-   **prependOptionValue**

    -   *Type:* string

    If specified, will provide an option at first position with the specified value.

-   **prioritizedCountries**

    -   *Type:* array
    -   *Default:* array (
    )

    A list of country codes which should be listed on top of the list.

-   **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.

-   **required**

    -   *Type:* boolean
    -   *Default:* false

    If set no empty value is allowed.

-   **sortByOptionLabel**

    -   *Type:* boolean
    -   *Default:* false

    If true, List will be sorted by label.

-   **value**

    -   *Type:* mixed

    Value of input tag
