Matrix Field Type¶
This Field represents and handles a table of rows and columns of data.
Name | Internal name | Expected input |
---|---|---|
Matrix |
ezmatrix |
array |
The Matrix Field Type is available via the Matrix Bundle provided by the ezplatform-matrix-fieldtype package.
PHP API Field Type¶
Input expectations¶
Type | Description | Example |
---|---|---|
array |
array of EzSystems\EzPlatformMatrixFieldtype\FieldType\Value\Row objects which contain column data |
see below |
Example of input:
1 2 3 4 5 |
|
Value Object¶
EzSystems\EzPlatformMatrixFieldtype\FieldType\Value
offers the following properties:
Property | Type | Description |
---|---|---|
rows |
RowsCollection |
Array of Row objects containing an array of cells (Row::getCells() returns array ['col1' => 'Value 1', /* ... */] ). |
Validation¶
The minimum number of rows is set on Content Type level for each Field.
Validation checks for empty rows. A row is considered empty if it contains only empty cells (or cells containing only spaces). Empty rows are removed.
If, after removing empty rows, the number of rows does not fulfill the configured Minimum number of rows
, the Field will not validate.
For example, the following input will not validate if Minimum number of rows
is set to 3, because the second row is empty:
1 2 3 4 5 |
|
GraphQL Field Type operations¶
To get a Field of the Matrix Field Type with GraphQL, you will need to specify a Content ID, a Content Type, and a Field Type.
The types that are returned are named after the Type and the Field:
{TypeIdentifier}{FieldIdentifier}Row
The example below shows a GraphQL query for a Recipe Content item (belonging to a Content Type with a Matrix Field added), that has two Fields:
name
:ezstring
ingredients
:ezmatrix
with two columns:ingredient
andquantity
1 2 3 4 5 6 7 8 9 10 11 |
|
The Type returned for the Matrix Field exposes columns defined in the Field definition:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Query for the Field Type and Field definition's details¶
With this query you can inspect details of specific Content Type. In case of a Matrix Field, you can ask for the list of columns, their names and identifiers.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
The response will list the exposed Field Type settings:
- minimumRows
- columns
- name
- identifier
Example response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
Mutation¶
To create a Matrix Field Type you need to define Field Type and Field definition identifiers. The types that are used for input are named after the Type and the Field:
{TypeIdentifier}{FieldIdentifier}RowInput
e.g.dish.nutritionFacts
,event.agenda
:DishNutritionFactsRowInput
,EventAgendaRowInput
The example below shows how to create a Recipe Content item (belonging to a Content Type with a Matrix Field Type added) that has two Fields:
name
:"Cake Ingredient List"
ingredients
:ezmatrix
with two columns:ingredient
andquantity
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
The response will confirm creation of the new Recipe Field:
1 2 3 4 5 6 7 |
|