General

  eZ Systems Website
  Editor documentation


  Developer documentation

  Back to the top

Versions Compared

Key

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

This Field Type represents one or multiple relations to content.

NameInternal nameExpected input
RelationListezobjectrelationlistmixed

Description

This Field Type makes possible to store and retrieve values of relation to content.

PHP API Field Type 

Input expectations

Type
Description
Example
int|stringId of the related Content item42
arrayAn array of related Content IDsarray( 24, 42 )
eZ\Publish\API\Repository\Values\Content\ContentInfo

ContentInfo instance of the related Content

 
eZ\Publish\Core\FieldType\RelationList\ValueRelationList Field Type Value ObjectSee Value Object documentation section below.

Value Object

API

Properties

eZ\Publish\Core\FieldType\RelationList\Value contains following properties.

PropertyTypeDescriptionExample

destinationContentIds

arrayAn array of related Content idsarray( 24, 42 )
Code Block
languagephp
titleValue object content example
linenumberstrue
$relationList->destinationContentId = array( 
	$contentInfo1->id,
	$contentInfo2->id,
	170
);
Constructor

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

Code Block
languagephp
titleConstructor example
linenumberstrue
// Instantiates a RelationList Value object
$relationListValue = new RelationList\Value(
	array(
		$contentInfo1->id,
		$contentInfo2->id,
		170		
	)
);

Validation

This Field Type validates if the selectionMethod specified is 0 (self::SELECTION_BROWSE) or 1 (self::SELECTION_DROPDOWN). A validation error is thrown if the value does not match.

Also validates if the selectionDefaultLocation specified is null, string or integer. If the type validation fails a validation error is thrown.

And validates if the value specified in selectionContentTypes is an array. If not, a validation error in given.

Settings

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

NameTypeDefault valueDescription

selectionMethod

mixed
SELECTION_BROWSE
Method of selection in the administration interface

selectionDefaultLocation

string|integernullId of the default Location for the selection when using administration interface

selectionContentTypes

arrayarray()An array of ContentType ids that are allowed for related Content

Following selection methods are available:

NameDescription
SELECTION_BROWSESelection will use browse mode
SELECTION_DROPDOWNSelection control will use dropdown control containing the Content list in the default Location for selection
Info

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

Code Block
languagephp
titleExample of using settings in PHP
linenumberstrue
use eZ\Publish\Core\FieldType\RelationList\Type;

$settings = array(
	"selectionMethod" => Type::SELECTION_BROWSE,
	"selectionDefaultLocation" => null,
    "selectionContentTypes" => array()
 );