Global navigation

   Documentation Center
   eZ Studio & eZ Platform
     User Manual
     Technical Manual
     Glossary
   eZ Publish 4.x / legacy

 
eZ Publish (5.x)

eZ Publish 5.x | For eZ Platform & eZ Studio topics see Technical manual and User manual, for eZ Publish 4.x and Legacy topics see eZ Publish legacy

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: add horizonal rules

This field type represents one or multiple countries.

NameInternal nameExpected input
Countryezcountryarray

Table of contents:

Table of Contents
minLevel2

Description


This FieldType makes possible to store and retrieve data representing countries.

Input expectations


TypeExample
array
Code Block
languagephp
linenumberstrue
array(
    "JP" => array(
	    "Name" => "Japan",
        "Alpha2" => "JP",
        "Alpha3" => "JPN",
        "IDC" => 81
    )
);

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

Validation


This FieldType validates if the multiple countries are allowed by the field definition, and if the Alpha2 is valid according to the countries configured in eZ Publish.

Settings


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

NameTypeDefault valueDescription
isMultiplebooleanfalseThis setting allows (if true) or denies (if false) the selection of multiple countries.
Code Block
languagephp
titleCountry FieldType example settings
linenumberstrue
$settings = array(
	"isMultiple" => true
);

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 value to a array instead of the Value object. Example of that shown below:

Code Block
languagephp
titleValue object content example
linenumberstrue
$content->fields["countries"] = array( "JP", "NO" );

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

Value object


Properties

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

PropertyTypeDescription
$countriesarray[]This property will be used for the country selection provided as input, as its attributes.
Code Block
languagephp
titleValue object content example
linenumberstrue
$value->countries = array(
    "JP" => array(
        "Name" => "Japan",
        "Alpha2" => "JP",
        "Alpha3" => "JPN",
        "IDC" => 81
    )
)

Constructor

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

Code Block
languagephp
titleConstructor example
linenumberstrue
// Instantiates a Country Value object
$countryValue = new Country\Value(
	array(
    	"JP" => array(
        	"Name" => "Japan",
        	"Alpha2" => "JP",
        	"Alpha3" => "JPN",
        	"IDC" => 81
		)
	)
);