diff --git a/public/modules/custom/asu_application/src/Plugin/Field/FieldWidget/ApplicantWidget.php b/public/modules/custom/asu_application/src/Plugin/Field/FieldWidget/ApplicantWidget.php index 8f43287a4..02b0e939c 100644 --- a/public/modules/custom/asu_application/src/Plugin/Field/FieldWidget/ApplicantWidget.php +++ b/public/modules/custom/asu_application/src/Plugin/Field/FieldWidget/ApplicantWidget.php @@ -77,13 +77,17 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen '#default_value' => $items->getValue()[$delta]['date_of_birth'] ?? '', ]; + $personal_id_default = !empty($items->getValue()[$delta]['personal_id']) + ? substr($items->getValue()[$delta]['personal_id'], -4) + : ''; + $element['personal_id'] = [ '#type' => 'textfield', '#title' => $this->t('Personal id'), '#description' => $this->t('last 4 characters'), - '#minlength' => 5, - '#maxlength' => 5, - '#default_value' => $items->getValue()[$delta]['personal_id'] ?? '', + '#minlength' => 4, + '#maxlength' => 4, + '#default_value' => $personal_id_default, ]; $element['address'] = [