diff --git a/src/bb-modules/Client/Api/Guest.php b/src/bb-modules/Client/Api/Guest.php index 969cccc9a..f35497328 100644 --- a/src/bb-modules/Client/Api/Guest.php +++ b/src/bb-modules/Client/Api/Guest.php @@ -95,6 +95,19 @@ class Guest extends \Api_Abstract } } + if (isset($config['custom_fields']) && is_array($config['custom_fields'])) { + foreach ($config['custom_fields'] as $cFieldName => $cField) { + $active = isset($cField['active']) && $cField['active'] ? true : false; + $required = isset($cField['required']) && $cField['required'] ? true : false; + if ($active && $required) { + if (!isset($data[$cFieldName]) || empty($data[$cFieldName])) { + $name = isset($cField['title']) && !empty($cField['title']) ? $cField['title'] : ucwords(str_replace('_', ' ', $cFieldName));; + throw new \Box_Exception('It is required that you provide details for field ":field"', array(':field' => $name)); + } + } + } + } + $this->di['validator']->isPasswordStrong($data['password']); $this->di['validator']->isEmailValid($data['email']); @@ -278,4 +291,13 @@ class Guest extends \Api_Abstract $config = $this->di['mod_config']('client'); return isset($config['required']) ? $config['required'] : array(); } + + /** + * Array of custom fields for client registration + */ + public function custom_fields() + { + $config = $this->di['mod_config']('client'); + return isset($config['custom_fields']) ? $config['custom_fields'] : array(); + } } \ No newline at end of file diff --git a/src/bb-modules/Client/html_admin/mod_client_settings.phtml b/src/bb-modules/Client/html_admin/mod_client_settings.phtml index 11965a502..422c83f73 100644 --- a/src/bb-modules/Client/html_admin/mod_client_settings.phtml +++ b/src/bb-modules/Client/html_admin/mod_client_settings.phtml @@ -20,6 +20,7 @@
@@ -74,20 +75,6 @@ - {# - - - - - - - - - - - - - #}
@@ -97,6 +84,25 @@ +
+
+ {% for i in 0..10 %} + {% set field_name = 'custom_' ~ i %} + {% set custom_field = attribute(params.custom_fields, field_name) %} +
+ +
+ + + +
+
+
+
+ {% endfor %} + +
+
diff --git a/src/bb-modules/Orderbutton/html_client/mod_orderbutton_client.phtml b/src/bb-modules/Orderbutton/html_client/mod_orderbutton_client.phtml index 1f514e2ee..45b7c1ff9 100644 --- a/src/bb-modules/Orderbutton/html_client/mod_orderbutton_client.phtml +++ b/src/bb-modules/Orderbutton/html_client/mod_orderbutton_client.phtml @@ -196,6 +196,19 @@ {% endif %} + {% set custom_fields = guest.client_custom_fields %} + {% for field_name, field in custom_fields %} + {% if field.active %} +
+ +
+ +

+
+
+ {% endif %} + {% endfor %} + {{ mf.recaptcha }}
diff --git a/src/bb-modules/Page/html_client/mod_page_signup.phtml b/src/bb-modules/Page/html_client/mod_page_signup.phtml index 621d56b5c..40616d477 100644 --- a/src/bb-modules/Page/html_client/mod_page_signup.phtml +++ b/src/bb-modules/Page/html_client/mod_page_signup.phtml @@ -15,7 +15,6 @@ {% endif %} {% endif %} -
@@ -159,6 +158,20 @@
{% endif %} + {% set custom_fields = guest.client_custom_fields %} + {% for field_name, field in custom_fields %} + {% if field.active %} +
+ +
+ +

+
+
+ {% endif %} + {% endfor %} + +
diff --git a/src/bb-themes/boxbilling/html/mod_cart_index.phtml b/src/bb-themes/boxbilling/html/mod_cart_index.phtml index 02637a3f8..e7b80150b 100644 --- a/src/bb-themes/boxbilling/html/mod_cart_index.phtml +++ b/src/bb-themes/boxbilling/html/mod_cart_index.phtml @@ -247,6 +247,19 @@

{% endif %} + {% set custom_fields = guest.client_custom_fields %} + {% for field_name, field in custom_fields %} + {% if field.active %} +
+ +
+ +

+
+
+ {% endif %} + {% endfor %} +

diff --git a/src/bb-themes/boxbilling/html/mod_page_login.phtml b/src/bb-themes/boxbilling/html/mod_page_login.phtml index 9d4464982..b1c229c2c 100644 --- a/src/bb-themes/boxbilling/html/mod_page_login.phtml +++ b/src/bb-themes/boxbilling/html/mod_page_login.phtml @@ -100,6 +100,19 @@

{% endif %} + + {% set custom_fields = guest.client_custom_fields %} + {% for field_name, field in custom_fields %} + {% if field.active %} +
+ +
+ +

+
+
+ {% endif %} + {% endfor %}