You are here

function farm_land_type_field_allowed_values in farmOS 2.x

Allowed values callback function for the land type field.

Return value

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

1 call to farm_land_type_field_allowed_values()
KmlImporter::buildForm in modules/core/import/modules/kml/src/Form/KmlImporter.php
Form constructor.
1 string reference to 'farm_land_type_field_allowed_values'
Land::buildFieldDefinitions in modules/asset/land/src/Plugin/Asset/AssetType/Land.php

File

modules/asset/land/farm_land.module, line 14
Land asset module.

Code

function farm_land_type_field_allowed_values() {

  /** @var \Drupal\farm_land\Entity\FarmLandTypeInterface[] $types */
  $types = \Drupal::entityTypeManager()
    ->getStorage('land_type')
    ->loadMultiple();
  $allowed_values = [];
  foreach ($types as $id => $type) {
    $allowed_values[$id] = $type
      ->getLabel();
  }
  return $allowed_values;
}