From 4eba33e1da4b3c6cd51d1a49a5b0466bda8a708a Mon Sep 17 00:00:00 2001 From: orakili Date: Thu, 2 Jun 2022 16:20:32 +0000 Subject: [PATCH] [RW-577] Fix deselection of career category when editing job --- .../custom/reliefweb_entities/src/Services/JobFormAlter.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/html/modules/custom/reliefweb_entities/src/Services/JobFormAlter.php b/html/modules/custom/reliefweb_entities/src/Services/JobFormAlter.php index 05fb1b849..7f20810be 100644 --- a/html/modules/custom/reliefweb_entities/src/Services/JobFormAlter.php +++ b/html/modules/custom/reliefweb_entities/src/Services/JobFormAlter.php @@ -54,7 +54,9 @@ protected function addBundleFormAlterations(array &$form, FormStateInterface $fo $this->addSelectionLimit($form, 'field_career_categories', 1); // Prevent Drupal from returning "An illegal choice was selected" error // message instead of indicating the field is mandatory. - $form['field_career_categories']['widget']['#default_value'] = NULL; + if (empty($form['field_career_categories']['widget']['#default_value'])) { + $form['field_career_categories']['widget']['#default_value'] = NULL; + } // Disable themes for some career categories and limit selection. $this->alterJobThemeField($form, $form_state);