Skip to content

Commit

Permalink
Добавил поле в настройки для валидации телефона:
Browse files Browse the repository at this point in the history
Вынести регулярку валидации телефона в системные настройки #770
  • Loading branch information
Electrica committed Mar 29, 2023
1 parent dcb0381 commit 62a40ff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions _build/data/transport.settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@
'area' => 'ms2_cart',
],

'ms2_order_format_phone' => [
'value' => '/[^-+()0-9]/u',
'xtype' => 'textfield',
'area' => 'ms2_order',
],
'ms2_order_format_num' => [
'value' => '%y%m',
'xtype' => 'textfield',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function validate($key, $value)
}
break;
case 'phone':
$value = preg_replace('/[^-+()0-9]/u', '', $value);
$value = $this->modx->getOption('ms2_order_format_phone', null, '/[^-+()0-9]/u');
break;
case 'delivery':
/** @var msDelivery $delivery */
Expand Down
2 changes: 2 additions & 0 deletions core/components/minishop2/lexicon/ru/setting.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
$_lang['setting_ms2_notify_js_class_path_desc'] = 'Путь указывается относительно папки assets/components/minishop2/js/web/modules';
$_lang['setting_ms2_order_address_fields'] = 'Поля адреса доставки';
$_lang['setting_ms2_order_address_fields_desc'] = 'Список полей доставки, которые будут показаны на третьей вкладке карточки заказа. Доступны: "receiver,phone,email,index,country,region,city,metro,street,building,entrance,floor,room,comment,text_address". Если параметр пуст, вкладка будет скрыта.';
$_lang['setting_ms2_order_format_phone'] = 'Формат валидации телефона';
$_lang['setting_ms2_order_format_phone_desc'] = 'Формат валидации телефона. Используется в функции preg_replace';
$_lang['setting_ms2_order_format_num'] = 'Формат нумерации заказа';
$_lang['setting_ms2_order_format_num_desc'] = 'Формат нумерации заказа. Доступные значения в формате PHP strftime()';
$_lang['setting_ms2_order_format_num_separator'] = 'Разделитель для нумерации заказа';
Expand Down

0 comments on commit 62a40ff

Please sign in to comment.