EasyAdmin Locale Field
This field is used to represent the name of a locale stored in a property as a valid ICU project locale code (the same which is used by Symfony and many other tech projects).
See also LanguageField and CountryField.
In form pages (edit and new) it looks like this:
Basic Information
- PHP Class:
EasyCorp\Bundle \EasyAdminBundle \Field \LocaleField - Doctrine DBAL Type used to store this value:
string - Symfony Form Type used to render the field: LocaleType
Rendered as:
1
<select> ... </select>
Options
includeOnly
By default, the locale selector displays all the locales defined by the ICU project. Use this option to only display the given locale codes:
1
yield LocaleField::new('...')->includeOnly(['en', 'fr', 'pl']);
remove
By default, the locale selector displays all the locales defined by the ICU project. Use this option to remove the given locale codes from that list:
1
yield LocaleField::new('...')->remove(['fr', 'pl']);
setBadgeVariant
When you use the showCode option, the locale code is displayed as a badge.
Use this option to change the visual style of that badge.
By default, it uses the badge variant configured with the setBadgeVariant()
method of the CRUD design options (light if
you don't configure it). The other values are solid, outline and dot.
This option only changes the badges of this field, not the badges of other fields:
1
yield LocaleField::new('...')->setBadgeVariant('dot');
showCode
By default, in read-only pages (index and detail) this field displays the
full name of the locale (e.g. Somali (Djibouti), Uyghur (China),
Ukrainian, etc.).
Use this option if you want to display the locale code (e.g. so_DJ,
ug_CN, uk, etc.) instead of or in addition to the locale name:
1
yield LocaleField::new('...')->showCode();
showName
By default, in read-only pages (index and detail) this field displays the
full name of the locale (e.g. Somali (Djibouti), Uyghur (China),
Ukrainian, etc.).
Use this option to hide the locale name. Combine it with showCode() to
display the locale code instead; otherwise the field displays nothing:
1
yield LocaleField::new('...')->showName(false);