From b40e1fc16287e47716c21b706bcb03aa6b2a5c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be> Date: Wed, 8 Aug 2018 12:50:42 +0000 Subject: [PATCH] Merge branch '5864-name-field-for-countries-should-be-limited-to-two-characters' into '1.3-dev' Resolve "Name field for countries should be limited to two characters" See merge request fusiondirectory/fd!350 (cherry picked from commit eef5e5addee8650142756272d7e88dd40e83d88c) 89af097f :ambulance: fix(country) Country c field is not a name but a two-letter country code --- 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 9003206e6..3fc3f5de4 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