Skip to content
Alberto Parziale edited this page Apr 28, 2020 · 1 revision

Group

Generating group of fields is simple. Let’s create a new config file, naming it “sample_group.json”. Like everywhere, we have three main fields available:

  • "name" defines the internal name for this config file.
  • "kind" defines the type of configuration: we’re gonna set it to "group" to create a group of fields.
  • "spec" defines our settings page specific configuration.
{
  "name": "sample_group",
  "spec": {},
  "kind": "group"
}

If you want to leave this configuration disabled for now, you can add "enabled": false to these fields.

Specs

Now that we've defined the basic informations about the group, we need to add some informations about what we need.

We can define a group of fields that we can reuse all around our configurations, using the same structure of meta's fields:

{
  "name": "author_info",
  "spec": {
    "fields": [
      {
        "type": "text",
        "id": "author-name",
        "label": "Author name"
      },
      {
        "type": "text",
        "id": "author-surname",
        "label": "Author surname"
      }
    ]
  },
  "kind": "group"
}

and then we can include it in other configuration like follows:

[...], // other specs
"fields": [
  [...], // other fields
  {
    "type": "group",
    "id": "author_info"
  },
  [...] // other fields
],
[...] // other specs
Clone this wiki locally