‪TYPO3CMS  ‪main
TYPO3\CMS\Fluid\ViewHelpers\Form\CountrySelectViewHelper Class Reference
Inheritance diagram for TYPO3\CMS\Fluid\ViewHelpers\Form\CountrySelectViewHelper:
TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewHelper

Public Member Functions

 initializeArguments ()
 
 render ()
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper
 injectConfigurationManager (ConfigurationManagerInterface $configurationManager)
 
 getRespectSubmittedDataValue ()
 
 setRespectSubmittedDataValue (bool $respectSubmittedDataValue)
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewHelper
 injectPersistenceManager (PersistenceManagerInterface $persistenceManager)
 

Public Attributes

 break
 
case __pad0__: $options[$code] = $country->getName()
 
case __pad1__: $options[$code] = $country->getOfficialName()
 
case __pad2__: $name = $this->translate($country->getLocalizedOfficialNameLabel())
 
if(! $name$options [$code] = $name
 
default __pad3__: throw new \TYPO3Fluid\Fluid\Core\ViewHelper\Exception('Argument "optionLabelField" of <f:form.countrySelect> must either be set to "localizedName"
 
default name
 
default officialName
 

Protected Member Functions

array< string, createOptions(array $countries):array { $options=[];foreach( $countries as $code=> $country) { switch( $this->arguments[ 'optionLabelField']) { case 'localizedName':$options[ $code]=$this-> translate ($country->getLocalizedNameLabel())
 
- ‪Protected Member Functions inherited from ‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper
 getName ()
 
RequestInterface getRequest ()
 
 getNameWithoutPrefix ()
 
mixed getValueAttribute ()
 
mixed getValueFromSubmittedFormData ($value)
 
mixed convertToPlainValue ($value)
 
 hasMappingErrorOccurred ()
 
mixed getLastSubmittedFormData ()
 
 addAdditionalIdentityPropertiesIfNeeded ()
 
mixed getPropertyValue ()
 
 isObjectAccessorMode ()
 
 setErrorClassAttribute ()
 
 getMappingResultsForProperty ()
 
 renderHiddenFieldForEmptyValue ()
 
- ‪Protected Member Functions inherited from ‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewHelper
 prefixFieldName (string $fieldName)
 
string renderHiddenIdentityField (?object $object, ?string $name)
 
 registerFieldNameForFormTokenGeneration (string $fieldName)
 

Protected Attributes

string $tagName = 'select'
 
- ‪Protected Attributes inherited from ‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper
ConfigurationManagerInterface $configurationManager
 
bool $respectSubmittedDataValue = false
 
- ‪Protected Attributes inherited from ‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewHelper
PersistenceManagerInterface $persistenceManager
 

Detailed Description

Renders a :html:<select> tag with all available countries as options.

Examples

Basic usage

::

<f:form.countrySelect name="country" value="{defaultCountry}" />

Output::

<select name="country"> <option value="BE">Belgium</option> <option value="FR">France</option> .... </select>

Prioritize countries

Define a list of countries which should be listed as first options in the form element::

<f:form.countrySelect name="country" value="AT" prioritizedCountries="{0: 'DE', 1: 'AT', 2: 'CH'}" />

Additionally, Austria is pre-selected.

Display another language

A combination of optionLabelField and alternativeLanguage 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::

<f:form.countrySelect name="country" optionLabelField="localizedOfficialName" alternativeLanguage="fr" sortByOptionLabel="true" />

Bind an object

You can also use the "property" attribute if you have bound an object to the form. See :ref:<f:form> <typo3-fluid-form> for more documentation.

Definition at line 82 of file CountrySelectViewHelper.php.

Member Function Documentation

◆ initializeArguments()

TYPO3\CMS\Fluid\ViewHelpers\Form\CountrySelectViewHelper::initializeArguments ( )

◆ render()

◆ translate()

array<string, createOptions(array $countries): array { $options = []; foreach ($countries as $code => $country) { switch ($this->arguments['optionLabelField']) { case 'localizedName': $options[$code] = $this-> TYPO3\CMS\Fluid\ViewHelpers\Form\CountrySelectViewHelper::translate (   $country->())
protected
Parameters
Country[]$countries
Returns
‪array<string, string>

Member Data Documentation

◆ $options

if (! $name) TYPO3\CMS\Fluid\ViewHelpers\Form\CountrySelectViewHelper::$options[ $code] = $name

◆ $tagName

string TYPO3\CMS\Fluid\ViewHelpers\Form\CountrySelectViewHelper::$tagName = 'select'
protected

Definition at line 86 of file CountrySelectViewHelper.php.

◆ __pad0__

case TYPO3\CMS\Fluid\ViewHelpers\Form\CountrySelectViewHelper::__pad0__

Definition at line 150 of file CountrySelectViewHelper.php.

◆ __pad1__

case TYPO3\CMS\Fluid\ViewHelpers\Form\CountrySelectViewHelper::__pad1__

Definition at line 153 of file CountrySelectViewHelper.php.

◆ __pad2__

case TYPO3\CMS\Fluid\ViewHelpers\Form\CountrySelectViewHelper::__pad2__

Definition at line 156 of file CountrySelectViewHelper.php.

◆ __pad3__

default TYPO3\CMS\Fluid\ViewHelpers\Form\CountrySelectViewHelper::__pad3__

Definition at line 163 of file CountrySelectViewHelper.php.

◆ break

TYPO3\CMS\Fluid\ViewHelpers\Form\CountrySelectViewHelper::break

Definition at line 149 of file CountrySelectViewHelper.php.

◆ name

default TYPO3\CMS\Fluid\ViewHelpers\Form\CountrySelectViewHelper::name

Definition at line 164 of file CountrySelectViewHelper.php.

◆ officialName

default TYPO3\CMS\Fluid\ViewHelpers\Form\CountrySelectViewHelper::officialName

Definition at line 164 of file CountrySelectViewHelper.php.