Skip to content
For AI agents: the complete documentation index is available at llms.txt; this page is also available as Markdown at index.md.

Relation field type

This field type makes it possible to store and retrieve the value of a relation to another content item.

Name Internal name Expected input
Relation ibexa_object_relation mixed

PHP API field type

Input expectations

Type Example
string "150"
integer 150

Value object

Properties

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

Property Type Description
$destinationContentId string, int, or null This property is used to store the value provided, which represents the related content.
1
2
3
4
5
6
7
/**
 * Value object content example.
 *
 * @var \Ibexa\Core\FieldType\Relation\Value $relation
 * @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo
 */
$relation->destinationContentId = $contentInfo->id;

Constructor

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

1
2
3
4
5
6
// Constructor example
use Ibexa\Core\FieldType\Relation as Relation;

/** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo */
// Instantiates a Relation Value object
$relationValue = new Relation\Value($contentInfo->id);

Validation

This field type validates whether the provided relation exists, but before that it checks that the value is either a string or an int.

Settings

The field definition of this field type can be configured with three options:

Name Type Default value Description
selectionMethod int Relation\Type::SELECTION_BROWSE This setting is not implemented yet, only one selection method is available.
selectionRoot string null This setting defines the selection root.
selectionContentTypes array [] An array of content type IDs that are allowed for related Content.
1
2
3
4
5
6
7
8
9
// Relation FieldType example settings

use Ibexa\Core\FieldType\Relation\Type;

$settings = [
    'selectionMethod' => 1,
    'selectionRoot' => null,
    'selectionContentTypes' => [],
];