mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-21 20:34:57 +09:00
Feature request: 'Custom fields for sign up form' implemented
This commit is contained in:
1 parent
a2200e1c1f
commit
43bfbb55aa
6 files changed
+95
-15
No files matched your search
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
<ul class="tabs">
|
||||
<li><a href="#tab-index">{% trans 'General' %}</a></li>
|
||||
<li><a href="#tab-custom-fields">{% trans 'Custom Fields' %}</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tabs_container">
|
||||
@@ -74,20 +75,6 @@
|
||||
<option value="phone" {% if 'phone' in params.required %}selected{% endif %}>{% trans 'Phone' %}</option>
|
||||
</optgroup>
|
||||
|
||||
{#
|
||||
<optgroup label="Custom fields">
|
||||
<option value="custom_1" {% if 'custom_1' in params.required %}selected{% endif %}>{% trans 'Custom_1' %}</option>
|
||||
<option value="custom_2" {% if 'custom_2' in params.required %}selected{% endif %}>{% trans 'Custom_2' %}</option>
|
||||
<option value="custom_3" {% if 'custom_3' in params.required %}selected{% endif %}>{% trans 'Custom_3' %}</option>
|
||||
<option value="custom_4" {% if 'custom_4' in params.required %}selected{% endif %}>{% trans 'Custom_4' %}</option>
|
||||
<option value="custom_5" {% if 'custom_5' in params.required %}selected{% endif %}>{% trans 'Custom_5' %}</option>
|
||||
<option value="custom_6" {% if 'custom_6' in params.required %}selected{% endif %}>{% trans 'Custom_6' %}</option>
|
||||
<option value="custom_7" {% if 'custom_7' in params.required %}selected{% endif %}>{% trans 'Custom_7' %}</option>
|
||||
<option value="custom_8" {% if 'custom_8' in params.required %}selected{% endif %}>{% trans 'Custom_8' %}</option>
|
||||
<option value="custom_9" {% if 'custom_9' in params.required %}selected{% endif %}>{% trans 'Custom_9' %}</option>
|
||||
<option value="custom_10" {% if 'custom_10' in params.required %}selected{% endif %}>{% trans 'Custom_10' %}</option>
|
||||
</optgroup>
|
||||
#}
|
||||
</select>
|
||||
|
||||
</div>
|
||||
@@ -97,6 +84,25 @@
|
||||
</fieldset>
|
||||
|
||||
</div>
|
||||
<div id="tab-custom-fields" class="tab_content nopadding">
|
||||
<fieldset>
|
||||
{% for i in 0..10 %}
|
||||
{% set field_name = 'custom_' ~ i %}
|
||||
{% set custom_field = attribute(params.custom_fields, field_name) %}
|
||||
<div class="rowElem noborder">
|
||||
<label>{% if custom_field.title is not empty %} {{custom_field.title}} ({% trans 'Custom_' %}{{ i }}) {% else %}{% trans 'Custom_' %}{{ i }}{% endif %}</label>
|
||||
<div class="formRight">
|
||||
<input type="checkbox" name="custom_fields[{{ field_name }}][active]" value="1"{% if custom_field.active %} checked="checked"{% endif %}/><label>{% trans 'Active' %}</label>
|
||||
<input type="checkbox" name="custom_fields[{{ field_name }}][required]" value="1"{% if custom_field.required %} checked="checked"{% endif %}/><label>{% trans 'Required' %}</label>
|
||||
<input type="text" placeholder="Field title" name="custom_fields[{{ field_name }}][title]" value="{{custom_field.title}}" style="width: 300px"/>
|
||||
</div>
|
||||
<div class="fix"></div>
|
||||
</div>
|
||||
<hr/>
|
||||
{% endfor %}
|
||||
<input type="submit" value="{% trans 'Update profile' %}" class="greyishBtn submitForm" />
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -196,6 +196,19 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% set custom_fields = guest.client_custom_fields %}
|
||||
{% for field_name, field in custom_fields %}
|
||||
{% if field.active %}
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="{{ field_name }}">{% if field.title is not empty %}{{ field.title }}{% else %} {{ field_name | capitalize }} {% endif %}</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="{{ field_name }}" id="{{ field_name }}" value="{{ attribute(request, field_name) }}" {% if field.required %}required="required"{% endif %}>
|
||||
<p class="help-block"></p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{{ mf.recaptcha }}
|
||||
|
||||
<div class="form-actions">
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
{% endif %}
|
||||
</h1>
|
||||
{% endif %}
|
||||
|
||||
<div class="data-block">
|
||||
<div class="data-container">
|
||||
<form method="post" action="" id="client-signup">
|
||||
@@ -159,6 +158,20 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% set custom_fields = guest.client_custom_fields %}
|
||||
{% for field_name, field in custom_fields %}
|
||||
{% if field.active %}
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="{{ field_name }}">{% if field.title is not empty %}{{ field.title }}{% else %} {{ field_name | capitalize }} {% endif %}</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="{{ field_name }}" id="{{ field_name }}" value="{{ attribute(request, field_name) }}" {% if field.required %}required="required"{% endif %}>
|
||||
<p class="help-block"></p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="reg-password">{% trans 'Password' %}</label>
|
||||
<div class="controls">
|
||||
|
||||
@@ -247,6 +247,19 @@
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% set custom_fields = guest.client_custom_fields %}
|
||||
{% for field_name, field in custom_fields %}
|
||||
{% if field.active %}
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="{{ field_name }}">{% if field.title is not empty %}{{ field.title }}{% else %} {{ field_name | capitalize }} {% endif %}</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="{{ field_name }}" id="{{ field_name }}" value="{{ attribute(request, field_name) }}" {% if field.required %}required="required"{% endif %}>
|
||||
<p class="help-block"></p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<p>
|
||||
<label>{% trans 'Password' %}: </label>
|
||||
<input type="password" name="password" value="" required="required" id="reg-password">
|
||||
|
||||
@@ -100,6 +100,19 @@
|
||||
</select>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% set custom_fields = guest.client_custom_fields %}
|
||||
{% for field_name, field in custom_fields %}
|
||||
{% if field.active %}
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="{{ field_name }}">{% if field.title is not empty %}{{ field.title }}{% else %} {{ field_name | capitalize }} {% endif %}</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="{{ field_name }}" id="{{ field_name }}" value="{{ attribute(request, field_name) }}" {% if field.required %}required="required"{% endif %}>
|
||||
<p class="help-block"></p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<p>
|
||||
<label>{% trans 'Password' %}: </label>
|
||||
|
||||
Reference in new issue
Block a user