form.countrySelect ViewHelper <f:form.countrySelect>
¶
Renders a <select>
tag with all available countries as options.
Examples¶
Basic usage¶
<f:form.countrySelect name="country" value="{defaultCountry}" />
Copied!
Output:
<select name="country">
<option value="BE">Belgium</option>
<option value="FR">France</option>
....
</select>
Copied!
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.
Copied!
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"
/>
Copied!
Bind an object¶
You can also use the "property" attribute if you have bound an object to the form. See <f:form> for more documentation.
Arguments¶
additionalAttributes¶
- DataType
- mixed
- Required
- false
- Description
- Additional tag attributes. They will be added directly to the resulting HTML tag.
data¶
- DataType
- mixed
- Required
- false
- Description
- Additional data-* attributes. They will each be added with a "data-" prefix.
aria¶
- DataType
- mixed
- Required
- false
- Description
- Additional aria-* attributes. They will each be added with a "aria-" prefix.
name¶
- DataType
- string
- Required
- false
- Description
- Name of input tag
value¶
- DataType
- mixed
- Required
- false
- Description
- Value of input tag
property¶
- DataType
- string
- Required
- false
- Description
- 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.
class¶
- DataType
- string
- Required
- false
- Description
- CSS class(es) for this element
dir¶
- DataType
- string
- Required
- false
- Description
- Text direction for this HTML element. Allowed strings: "ltr" (left to right), "rtl" (right to left)
id¶
- DataType
- string
- Required
- false
- Description
- Unique (in this file) identifier for this HTML element.
lang¶
- DataType
- string
- Required
- false
- Description
- Language for this element. Use short names specified in RFC 1766
style¶
- DataType
- string
- Required
- false
- Description
- Individual CSS styles for this element
title¶
- DataType
- string
- Required
- false
- Description
- Tooltip text of element
accesskey¶
- DataType
- string
- Required
- false
- Description
- Keyboard shortcut to access this element
tabindex¶
- DataType
- integer
- Required
- false
- Description
- Specifies the tab order of this element
onclick¶
- DataType
- string
- Required
- false
- Description
- JavaScript evaluated for the onclick event
size¶
- DataType
- string
- Required
- false
- Description
- Size of select field, a numeric value to show the amount of items to be visible at the same time - equivalent to HTML <select> site attribute
disabled¶
- DataType
- string
- Required
- false
- Description
- Specifies that the input element should be disabled when the page loads
excludeCountries¶
- DataType
- mixed
- Default
- array ()
- Required
- false
- Description
- Array with country codes that should not be shown.
onlyCountries¶
- DataType
- mixed
- Default
- array ()
- Required
- false
- Description
- If set, only the country codes in the list are rendered.
optionLabelField¶
- DataType
- string
- Default
- 'localizedName'
- Required
- false
- Description
- If specified, will call the appropriate getter on each object to determine the label. Use "name", "localizedName", "officialName" or "localizedOfficialName"
sortByOptionLabel¶
- DataType
- boolean
- Required
- false
- Description
- If true, List will be sorted by label.
errorClass¶
- DataType
- string
- Default
- 'f3-form-error'
- Required
- false
- Description
- CSS class to set if there are errors for this ViewHelper
prependOptionLabel¶
- DataType
- string
- Required
- false
- Description
- If specified, will provide an option at first position with the specified label.
prependOptionValue¶
- DataType
- string
- Required
- false
- Description
- If specified, will provide an option at first position with the specified value.
multiple¶
- DataType
- boolean
- Required
- false
- Description
- If set multiple options may be selected.
required¶
- DataType
- boolean
- Required
- false
- Description
- If set no empty value is allowed.
prioritizedCountries¶
- DataType
- mixed
- Default
- array ()
- Required
- false
- Description
- A list of country codes which should be listed on top of the list.
alternativeLanguage¶
- DataType
- string
- Required
- false
- Description
- If specified, the country list will be shown in the given language.