General

  eZ Systems Website
  Technical documentation
  Editor documentation

This Documentation contains:
 
Technical documentation:



⚠ WARNING ! This documentation is deprecated !

Please go to the current Technical Documentation

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

...

Table of Contents
minLevel2

Description

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

...

Properties

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

...

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

Code Block
languagephp
titleConstructor example
// Instanciates a selection value with items #1 and #2 selected
$selectionValue = new Selection\Value( array( 1, 2 ) );

...

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

...

Hash format

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

Code Block
languagephp
titleExample of value in hash format
linenumberstrue
$hash = array( 1, 2 );

Validation

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

...

NameTypeDefault valueDescription
isMultiplebooleanfalseUsed to allow or deny multiple selection from the option list.
optionshasharray()Stores the list of options defined in the field definition.
Code Block
titleSelection FieldType Field Type example settings
use eZ\Publish\Core\FieldType\Selection\Type;
 
$settings = array(
    "isMultiple" => true,
    "options" => array(1 => 'One', 2 => 'Two', 3 => 'Three')
);