General

  eZ Systems Website
  Editor documentation


  Developer documentation

  Back to the top

The documentation is moving!

We're moving our developer docs to Github and a new site.
The migration is still in progress, so please contact us in #documentation-contrib on eZ Community Slack if you have any questions or feedback.

This space will not be updated from now on except for critical fixes.

Versions Compared

Key

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

This Field Type represents a relation to a Content item.

NameInternal nameExpected input
Relationezobjectrelationmixed

Description

This Field Type makes it possible to store and retrieve the value of relation to a Content item.

PHP API Field Type 

Input expectations

TypeExample
string
"150"
integer 150

Value object

Properties

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

PropertyTypeDescription
$destinationContentIdstring|int|nullThis property will be used to store the value provided, which will represent the related content.
Code Block
languagephp
titleValue object content example
$relation->destinationContentId = $contentInfo->id;
Constructor

The Relation\Value constructor will initialize a new Value object with the value provided. It expects a mixed value.

Code Block
languagephp
titleConstructor example
// Instantiates a Relation Value object
$relationValue = new Relation\Value( $contentInfo->id );

Validation

This Field Type validates whether the provided relation exists, but before it does that it will check that the value is either string or int.

Settings

The field definition of this Field Type can be configured with two options:

NameTypeDefault valueDescription
selectionMethodintself::SELECTION_BROWSE

This setting defines the selection method. It expects an integer (0/1). 0 stands for self::SELECTION_BROWSE, 1 stands for self::SELECTION_DROPDOWN.

 

Info

NOTE: Dropdown not implemented in Platform UI yet, only browse is used currently.

selectionRootstringnullThis setting defines the selection root.
Code Block
languagephp
titleRelation FieldType example settings
use eZ\Publish\Core\FieldType\Relation\Type;

$settings = array(
	"selectionMethod" => 1,
	"selectionRoot" => null
);

Note: These settings are meant for future use in user interface when allowing users to select relations.