Edit on GitHub


The block data type acts as a simple container for other data fields. Similar to a field collection, an unlimited number of block elements can be created.

A block element can be placed into a localized field but can also contain a localized field itself. Nesting is not possible.

Block data type

Block, edit peview

The block data basically just gets serialized into a single database column. As a consequence, this container type is not suitable, if you are planning to query the data.

API Usage

Let us consider the following class definition

Class Definition

and object data

Class Definition

The value of the second input field can be retrieved as follows:

        $object = Object\BlockClass::getById(48);
        /** @var  $blockData Object\ClassDefinition\Data\Block */
        $blockItems = $object->getBlockElement1();
        /** @var  $firstBlockItem Object\Data\BlockElement */
        $firstBlockItem = $blockItems[0];

The output will be "value2".

The value can be updated in a similar way.

        // ... same as above ...

Create a Block:

 * @var  $blockElement Object\Data\BlockElement
 * BlockElement( name, type, data )
$blockElement = new BlockElement( 'date', 'date', Carbon::now() );