44 lines
1.3 KiB
PHP
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,
|
|
]);
|
|
}
|
|
}
|