Message-ID: <2142927418.3892.1485855807902.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3891_692449455.1485855807902" ------=_Part_3891_692449455.1485855807902 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html The Country FieldType

The Country FieldType

This field type represents one or multiple countries.

Name Internal name Expected input
Country ezcountry array

Table of contents:

=20 =20

Description


This FieldType makes possible to store and retrieve data representing co= untries.

Input expectations


Type Example
array
=20
array(
    "JP" =3D> array(
=09    "Name" =3D> "Japan",
        "Alpha2" =3D> "JP",
        "Alpha3" =3D> "JPN",
        "IDC" =3D> 81
    )
);
=20

Note: When you set a array directly on Content field = you don't need to provide all this information, the FieldType will assume i= t is a hash and in this case it will accept a simplified structure describe= d below in the To / From Hash format.

Validation


This FieldType validates if the multiple countries are allowed by the fi= eld definition, and if the Alpha2 is valid according to the countries confi= gured in eZ Publish.

Settings


The field definition of this FieldType can be configured with one option= :

Name Type Default value Description
isMultiple boolean false This setting allows (if true) or denies (if fals= e) the selection of multiple countries.
Country FieldType example settings
=20
$settings =3D array(
=09"isMultiple" =3D> true
);
=20

To / From Hash format


The format used for serialization is simpler then the full format, this = is also available when setting value on the content field, by setting the v= alue to a array instead of the Value object. Example of that shown below:

Value object content example
=20
$content->fields["countries"] =3D array( "JP", "NO" );
=20

The format used by the toHash method is the Alpha2 value, however the in= put is cable of accepting either Name, Alpha2 or Alpha3 value as shown belo= w in the Value object section.

Value object


Properties

The Value class of this field type contains the following properties:

Property Type Description
$countries array[] This property will be used for the= country selection provided as input, as its attributes.
Value object content example
=20
$value->countries =3D array(
    "JP" =3D> array(
        "Name" =3D> "Japan",
        "Alpha2" =3D> "JP",
        "Alpha3" =3D> "JPN",
        "IDC" =3D> 81
    )
)
=20

Constructor

The Country\Value cons= tructor will initialize a new Value object with the value provided. It= expects an array as input.

Constructor example
=20
// Instantiates a Country Value object
$countryValue =3D new Country\Value(
=09array(
    =09"JP" =3D> array(
        =09"Name" =3D> "Japan",
        =09"Alpha2" =3D> "JP",
        =09"Alpha3" =3D> "JPN",
        =09"IDC" =3D> 81
=09=09)
=09)
);
=20
------=_Part_3891_692449455.1485855807902--