You are here

function opigno_module_update_8017 in Opigno module 8

Add levels for skills.

File

./opigno_module.install, line 1150
Opigno module app install/update functionality.

Code

function opigno_module_update_8017() {

  // Create a new field definition.
  $definition_manager = \Drupal::entityDefinitionUpdateManager();
  $options = [
    1 => 'Level 1',
  ];
  $field = BaseFieldDefinition::create('list_string')
    ->setLabel(t('Level of skill'))
    ->setRevisionable(TRUE)
    ->setTranslatable(TRUE)
    ->setDefaultValue('local')
    ->setRequired(TRUE)
    ->setSetting('allowed_values', $options)
    ->setDisplayOptions('form', [
    'type' => 'options_select',
    'weight' => 3,
  ]);
  $definition_manager
    ->installFieldStorageDefinition('skill_level', 'opigno_activity', 'opigno_module', $field);
}