fixed bugs in entity type relations/widgets

This commit is contained in:
naomi 2018-06-18 16:29:24 +02:00
parent 050bee1a9b
commit 1878d1e2fd
2 changed files with 5 additions and 1 deletions

View File

@ -20,6 +20,8 @@ class EntityTypeRelations {
public static function getAllowedActivityTypesForCaseType($case_type) { public static function getAllowedActivityTypesForCaseType($case_type) {
$caseTypeConfig = \Drupal::entityTypeManager()->getStorage('oc_case_type')->load($case_type); $caseTypeConfig = \Drupal::entityTypeManager()->getStorage('oc_case_type')->load($case_type);
return $caseTypeConfig->get('allowedActivityTypes'); // format: ['application' => 'application', 'interview' => 0] $allowedActivityTypes = $caseTypeConfig->get('allowedActivityTypes'); // format: ['application' => 'application', 'interview' => 0]
if (!$allowedActivityTypes) $allowedActivityTypes = array();
return $allowedActivityTypes;
} }
} }

View File

@ -47,6 +47,8 @@ class EntityTypeRelationsWidget {
public function populate(&$form) { public function populate(&$form) {
$case_type = $form['id']['#default_value']; $case_type = $form['id']['#default_value'];
$allowedActorTypes = EntityTypeRelations::getAllowedActorTypesForCaseType($case_type); $allowedActorTypes = EntityTypeRelations::getAllowedActorTypesForCaseType($case_type);
$form['allowed_actor_types']['#default_value'] = $allowedActorTypes;
$allowedActivityTypes = EntityTypeRelations::getAllowedActivityTypesForCaseType($case_type);
$form['allowed_activity_types']['#default_value'] = $allowedActivityTypes; $form['allowed_activity_types']['#default_value'] = $allowedActivityTypes;
} }