Files
farmOS-dev/web/profiles/farm/modules/log/transplanting/farm_transplanting.module
2024-12-10 15:08:16 +01:00

44 lines
1.3 KiB
PHP

<?php
/**
* @file
* Contains farm_transplanting.module.
*/
use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
/**
* Implements hook_entity_form_display_alter().
*/
function farm_transplanting_entity_form_display_alter(EntityFormDisplayInterface $form_display, array $context) {
if ($context['entity_type'] == 'taxonomy_term' && $context['bundle'] == 'plant_type' && $form_display->getMode() == 'default' && $form_display->isNew()) {
$form_display->setComponent('transplant_days', [
'type' => 'number',
'settings' => [
'placeholder' => '',
],
'region' => 'content',
'weight' => 15,
]);
}
}
/**
* Implements hook_entity_view_display_alter().
*/
function farm_transplanting_entity_view_display_alter(EntityViewDisplayInterface $display, array $context) {
if ($context['entity_type'] == 'taxonomy_term' && $context['bundle'] == 'plant_type' && $display->getMode() == 'full' && $display->isNew()) {
$display->setComponent('transplant_days', [
'type' => 'number_integer',
'label' => 'inline',
'settings' => [
'thousand_separator' => '',
'prefix_suffix' => TRUE,
],
'region' => 'content',
'weight' => 15,
]);
}
}