Custom Fields

Page Module

It is often required to add more fields to a page than the default provided ones. For this reason you can add any type of custom field to the Page Module.

For an in-depth overview you can watch the following video on adding custom fields to the page module.


Defining the fields

In the Page module config file located at Config/ you'll see the following configuration options:

'partials' => [
    'translatable' => [
        'create' => [],
        'edit' => [],
    'normal' => [
        'create' => [],
        'edit' => [],

In these arrays you can give on array of fields for translatable fields (create & edit) and non translatable fields (create & edit). Those will be shown on the page create and edit views.

Defining the relation

In that same config file you'll also see a relations key, just as with the User module, you can add dynamic relations with the Page entity. This will mostly be with your custom module that will have the entity with the additional data to be stored


The way to 'intercept' the posted data, is by hooking into the PageWasCreated and PageWasUpdated events. These events both have the pageId (int) and data (array). The data contains the posted data.


With the configuration setup, and your event handlers in place, you'll have the custom data stored in database. To display the data you can simply call the relation you setup in the configuration as a method.


Mobile Analytics