fixed return type of client_id callback when creating a case

This commit is contained in:
naomi 2021-12-04 16:58:18 +00:00
parent 0de22b7e90
commit 4b84c99541

View File

@ -11,6 +11,11 @@ use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;
function opencase_defaults_client_callback():array {
return [\Drupal::request()->query->get('client_id')];
}
/**
* Implements hook_help().
*/
@ -55,6 +60,21 @@ function opencase_defaults_entity_base_field_info($entity_type) {
'weight' => -6,
));
}
if ($entity_type->id() === 'oc_case') {
$fields['client'] = BaseFieldDefinition::create('entity_reference')
->setLabel('Client')
->setSetting('target_type', 'oc_actor')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setCardinality(1)
->setSetting('handler_settings', [
['target_bundles' => ['client' => 'client'] ]
])
->setDisplayConfigurable('form', true)
->setDisplayConfigurable('view', true)
->setDefaultValueCallback('opencase_defaults_client_callback')
->setRequired(TRUE);
}
return $fields;
}