What happened?
Description
When having a country field added to the sources of the index page of an entry type you get the error Illegal offset type

Steps to reproduce
- Create a country field
- Add the field to an entry type
- Add the country field to the index page of the entry
Expected behavior
Not throwing an error and show a preview of the field.
Actual behavior
Throwing the error Illegal offset type
A possible fix could be
craftcms/cms/src/fields/Country.php
public function getPreviewHtml(mixed $value, ElementInterface $element): string
{
if (!$value || !$value instanceof CountryModel) {
return '';
}
$list = Craft::$app->getAddresses()->getCountryRepository()->getList(Craft::$app->language);
return $list[$value->getCountryCode()] ?? $value;
}
Craft CMS version
5.3.4
PHP version
8.3
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
What happened?
Description
When having a country field added to the sources of the index page of an entry type you get the error
Illegal offset typeSteps to reproduce
Expected behavior
Not throwing an error and show a preview of the field.
Actual behavior
Throwing the error
Illegal offset typeA possible fix could be
craftcms/cms/src/fields/Country.php
Craft CMS version
5.3.4
PHP version
8.3
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions