You are here

function farm_lab_test_type_field_allowed_values in farmOS 2.x

Allowed values callback function for the lab test type field.

Return value

array Returns an array of allowed values for use in form select options.

1 string reference to 'farm_lab_test_type_field_allowed_values'
LabTest::buildFieldDefinitions in modules/log/lab_test/src/Plugin/Log/LogType/LabTest.php

File

modules/log/lab_test/farm_lab_test.module, line 14
The farmOS lab test log module.

Code

function farm_lab_test_type_field_allowed_values() {

  /** @var \Drupal\farm_lab_test\Entity\FarmLabTestTypeInterface[] $lab_test_types */
  $lab_test_types = \Drupal::entityTypeManager()
    ->getStorage('lab_test_type')
    ->loadMultiple();
  $allowed_values = [];
  foreach ($lab_test_types as $id => $lab_test_type) {
    $allowed_values[$id] = $lab_test_type
      ->getLabel();
  }
  return $allowed_values;
}