diff --git a/inc/container.class.php b/inc/container.class.php index 921adf0b..f715f9c3 100644 --- a/inc/container.class.php +++ b/inc/container.class.php @@ -355,13 +355,22 @@ function prepareInputForAdd($input) { } } - // construct field name by processing label - // (remove non alphanumeric char and any trailing spaces) - $input['name'] = strtolower(preg_replace("/[^\da-z]/i", "", preg_replace('/s*$/', '', $input['label']))); - // if empty, uses a random number + // Construct field name by processing label + $name = strtolower($input['label']); + // 1. remove trailing "s" (plural forms) + $name = preg_replace('/s*$/', '', $name); + // 2. keep only alphanum + $input['name'] = preg_replace('/[^\da-z]/i', '', $name); + // 3. if empty, uses a random number if (strlen($input['name']) == 0) { $input['name'] = rand(); } + // 4. replace numbers by letters + $name = str_replace( + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], + ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'], + $name + ); //check for already existing container with same name $found = $this->find(['name' => $input['name']]);