From c9778e71b96b85ee6082f91bb52914aca010b2a9 Mon Sep 17 00:00:00 2001
From: iBNu Maksum <me@ibnux.net>
Date: Tue, 19 Nov 2024 18:18:51 +0700
Subject: [PATCH] fix option select custom field

---
 system/controllers/customfield.php | 2 +-
 system/lan/english.json            | 6 +++++-
 ui/ui/customer/custom_field.tpl    | 4 ++--
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/system/controllers/customfield.php b/system/controllers/customfield.php
index b63b7a42..def4480f 100644
--- a/system/controllers/customfield.php
+++ b/system/controllers/customfield.php
@@ -23,7 +23,7 @@ switch ($action) {
             if(!empty($_POST['name'][$n])){
                 $datas[] = [
                     'order' => $_POST['order'][$n],
-                    'name' => $_POST['name'][$n],
+                    'name' => Text::alphanumeric(strtolower(str_replace(" ", "_", $_POST['name'][$n])), "_"),
                     'type' => $_POST['type'][$n],
                     'placeholder' => $_POST['placeholder'][$n],
                     'value' => $_POST['value'][$n],
diff --git a/system/lan/english.json b/system/lan/english.json
index 17690130..73189be7 100644
--- a/system/lan/english.json
+++ b/system/lan/english.json
@@ -911,5 +911,9 @@
     "Don_t_have_an_account_": "Don&#39;t have an account?",
     "You_do_not_have_permission_to_access_this_page_in_demo_mode": "You do not have permission to access this page in demo mode",
     "Custom_Fields": "Custom Fields",
-    "New_Field": "New Field"
+    "New_Field": "New Field",
+    "Data_Change": "Data Change",
+    "Photo": "Photo",
+    "Home_Address": "Home Address",
+    "Email_Address": "Email Address"
 }
\ No newline at end of file
diff --git a/ui/ui/customer/custom_field.tpl b/ui/ui/customer/custom_field.tpl
index 257dded6..de48a91e 100644
--- a/ui/ui/customer/custom_field.tpl
+++ b/ui/ui/customer/custom_field.tpl
@@ -1,6 +1,6 @@
 {if $register}
     <div class="form-group">
-        <label>{ucwords($field['name'])}</label>
+        <label>{ucwords(str_replace('_',' ', $field['name']))}</label>
         {if $field['type'] == 'option'}
             <select class="form-control" {if $field['required'] == 1} required{/if} name="{$field['name']}" style="width: 100%">
                 {assign var="opts" value=explode(',', $field['value'])}
@@ -18,7 +18,7 @@
     </div>
 {else}
     <div class="form-group">
-        <label class="col-md-3 control-label">{ucwords($field['name'])}</label>
+        <label class="col-md-3 control-label">{ucwords(str_replace('_',' ', $field['name']))}</label>
         <div class="col-md-9">
             {if $field['type'] == 'option'}
                 <select class="form-control" {if $field['required'] == 1} required{/if} name="{$field['name']}"