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

Selection Field Type

=20
=20
=20
=20

This Field Type represents a single selection or multiple choices from a= list of options.

Name Internal name Expected input type
Selection ezselection mixed

Description

The Selection Field Type stores single selections or mult= iple choices from a list of options, by populating a hash with the list of = selected values.

PHP API Field Type

Input expectations

Type Example
array array( 1, 2 )

Value object

Properties

The Value class of this Field Type contains the following properties:

Property Type Description
$selection int[] This property will be used for the list of selec= tions, which will be a list of integer values, or one single integer value.=
Value object content examples
=20
// Single selection
$value->selection =3D 1;=20
=20
// Multiple selection
$value->selection =3D array( 1, 4, 5 ); 
=20
Constructor

The Selection\Value constructor accepts an array = of selected element identifiers.

Constructor example
=20
// Instanciates a selection value with items #1 and #2 selected
$selectionValue =3D new Selection\Value( array( 1, 2 ) );
=20
String representation

String representation of this Field Type is its list of selections as a = string, concatenated with a comma.

Example:

"1,2,24,42"

Hash format

Hash format of this Field Type is the same as Value object's selection property.

Example of value in hash format
=20
$hash =3D array( 1, 2 );
=20

Validation

This Field Type validates the input, verifying if all selected options e= xist in the field definition and checks if multiple selections are allowed = in the Field definition.
If any of these validations fail, a ValidationError  = is thrown, specifying the error message, and for the case of the option val= idation a list with the invalid options is also presented.

Settings


Name Type Default value Description
isMultiple boolean false Used to allow or deny multiple selection from th= e option list.
options hash array() Stores the list of options defined in the field = definition.
Selection Field Type example settings
=20
use eZ\Publish\Core\FieldType\Selection\Type;
=20
$settings =3D array(
    "isMultiple" =3D> true,
    "options" =3D> array(1 =3D> 'One', 2 =3D> 'Two', 3 =3D> 'Th=
ree')
);
=20
=20
=20
=20
=20

 

=20
=20
=20
------=_Part_4135_1140241002.1485857839583--