Adding custom training fields

Users with Opigno Administrator role can use:
1

Step 1

Trainings
2

Step 2

Training settings
Trainings -> Training settings menu item to add custom fields of the following types to the Training entity (opigno_training):
  • text fields (string, string_long, text_long)
  • numeric fields (float, decimal, integer)
  • boolean
  • entity reference (only taxonomy term)
  • selection list (list_string, list_integer, list_float)
NoteAPI structure of the field depends on its cardinality and settings. It’s important to clear the Drupal cache every time when the field configuration is changed.
Once the field is added, it will immediately appear on the learning path form (field display settings can be updated using Manage form display tab on Trainings -> Training settings page:
1

Step 1

Manage form display tab on Trainings
2

Step 2

Training settings

Using custom training fields in Opigno API

The field will appear in API under the Training object after the Drupal cache clearing. The field name in the API will be the same as the Drupal machine name, without field_ prefix. For example, if the machine name is field_custom_field then in API it will appear as custom_field.
query getLearningPath {
  getLearningPath(lpId: "40") {
    training {
      custom_field {
        id
        name
        weight
      }
    }
  }
}

Using custom fields as catalog filters

Fields of the following types will be automatically available as the catalog filters:
  1. entity_reference that implements a reference to taxonomy terms;
  2. list_string;
  3. list_integer;
  4. list_float.
The filter name in the API will be generated based on the Drupal machine name without field_ prefix. For example, if the machine name is field_custom_field then in API an appropriate filter name will be filter_custom_field.
query getCatalogFilters {
  getCatalogFilters {
    id
    label
    formElementType
    filterFormSection
    options {
      key
      value
      weight
    }
  }
}