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 @@
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 %} +