public function Material::buildFieldDefinitions in farmOS 2.x
Same name in this branch
- 2.x modules/asset/material/src/Plugin/Asset/AssetType/Material.php \Drupal\farm_material\Plugin\Asset\AssetType\Material::buildFieldDefinitions()
- 2.x modules/quantity/material/src/Plugin/Quantity/QuantityType/Material.php \Drupal\farm_quantity_material\Plugin\Quantity\QuantityType\Material::buildFieldDefinitions()
Overrides QuantityTypeBase::buildFieldDefinitions
File
- modules/
quantity/ material/ src/ Plugin/ Quantity/ QuantityType/ Material.php, line 20
Class
- Material
- Provides the material quantity type.
Namespace
Drupal\farm_quantity_material\Plugin\Quantity\QuantityTypeCode
public function buildFieldDefinitions() {
// Inherit default quantity fields.
$fields = parent::buildFieldDefinitions();
// Material type.
$options = [
'type' => 'entity_reference',
'label' => $this
->t('Material type'),
'description' => $this
->t('What type of materials are being applied?'),
'target_type' => 'taxonomy_term',
'target_bundle' => 'material_type',
'auto_create' => TRUE,
'weight' => [
'form' => -50,
'view' => -50,
],
];
$fields['material_type'] = $this->farmFieldFactory
->bundleFieldDefinition($options);
return $fields;
}