From 89af097f670e86c51bfe678e6a94aa30975bb156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be> Date: Wed, 8 Aug 2018 14:28:03 +0200 Subject: [PATCH] :ambulance: fix(country) Country c field is not a name but a two-letter country code This will make sure the user enter a valid value to avoid invalid DN syntax errors. issue #5864 --- plugins/admin/departments/class_country.inc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/admin/departments/class_country.inc b/plugins/admin/departments/class_country.inc index ddc06d92b..fc6a3cb94 100644 --- a/plugins/admin/departments/class_country.inc +++ b/plugins/admin/departments/class_country.inc @@ -50,8 +50,14 @@ class country extends department $attributesInfo = parent::getDepartmentAttributesInfo(_('country')); unset($attributesInfo['location']); unset($attributesInfo['properties']['attrs'][3]); // category - /* Country c attribut cannot contain any underscore */ - $attributesInfo['properties']['attrs'][1]->setPattern('/^[a-z0-9\.-]+$/i'); + /* Replace Name field by country code */ + $attributesInfo['properties']['attrs'][1] = + new StringAttribute( + _('Country code'), _('A two-letter country code from ISO 3166'), + static::$namingAttr, TRUE, + '', '', + '/^[a-z0-9\.-]{2}$/i', 'IT' + ); return $attributesInfo; } } -- GitLab