diff --git a/web/themes/custom/reha/reha.theme b/web/themes/custom/reha/reha.theme index d05dd66..1f17dc1 100644 --- a/web/themes/custom/reha/reha.theme +++ b/web/themes/custom/reha/reha.theme @@ -117,10 +117,12 @@ function reha_preprocess_block(&$variables) { function reha_preprocess_field(&$variables){ if($variables['field_name'] === 'field_adresse_site'){ foreach($variables['items'] as $index => $adr){ - $postal_code = $variables['items'][$index]['content']['postal_code']['#value']; - $pattern = '/(\d{2})(\d+)/i'; - $replacement = '($1)'; - $variables['items'][$index]['content']['postal_code']['#value'] = preg_replace($pattern, $replacement, $postal_code); + if (isset($variables['items'][$index]['content']['postal_code'])) { + $postal_code = $variables['items'][$index]['content']['postal_code']['#value']; + $pattern = '/(\d{2})(\d+)/i'; + $replacement = '($1)'; + $variables['items'][$index]['content']['postal_code']['#value'] = preg_replace($pattern, $replacement, $postal_code); + } } } } \ No newline at end of file