{% if not field.custom_field %}
    {% if field.show %}
        {% if key  !=  'customer_group_id' %}
			<div id="regular-field-{{ key}}" class="form-group regular-field {{ field.required?'required': ''}}">
                {% if field.tooltip %}
    				<label class="col-sm-2 control-label" for="input-{{ key}}"><span data-toggle="tooltip" title="{{ field.tooltip }}">{{ field.title }}</span></label>
                {% else %}
    				<label class="col-sm-2 control-label" for="input-{{ key}}">{{ field.title }}</label>
                {% endif %}
    			<div class="col-sm-10">
                {% if field.type in ['text','date','datetime','password','email','tel'] %}
    				<input type="{{ field.type}}" name="{{ key }}" value="{{ field.value }}" {{ field.required  and  field.maximum ?'maxlength="'~field.maximum~'"': ''}} placeholder="{{ field.title }}" id="input-{{ key}}" class="form-control{{ field.required  and  field.numeric ?' '~field.numeric: ''}}{{ field.is_mask ?' mask': ''}}" />
                {% elseif  field.type  ==  'select' %}
    				<select name="{{ key}}" id="input-{{ key}}" class="form-control">
                        {% for option in field.select_values %}
    						<option value="{{ option.value_id }}" {{ field.value == option.value_id?'selected="selected"': ''}}>{{ option.display_name }}</option>
                        {% endfor %}
    				</select>
                {% endif %}
                {% if field.error %}
    				<div class="text-danger">{{ field.error }}</div>
                {% endif %}
    			</div>
			</div>
         {% else %}
			<div id="regular-field-{{ key}}" class="form-group required" style="display: {{ customer_groups|length  > 1 ? 'block' : 'none' }};">
            	<label class="col-sm-2 control-label">{{ entry_customer_group }}</label>
            	<div class="col-sm-10">
              	{% for customer_group in customer_groups %}
                  {% if customer_group.customer_group_id  ==  customer_group_id %}
              		<div class="radio">
                		<label>
                  			<input type="radio" name="customer_group_id" value="{{ customer_group.customer_group_id }}" checked="checked" />
                          {{ customer_group.name }}
                        </label>
              		</div>
                   {% else %}
                    <div class="radio">
                        <label>
                          <input type="radio" name="customer_group_id" value="{{ customer_group.customer_group_id }}" />
                          {{ customer_group.name }}</label>
                      </div>
			       {% endif %}
			    {% endfor %}
            </div>
          </div>
        {% endif %}
{% else %}
 <input type="hidden" name="{{ key }}" value="{{ field.value }}" />
{% endif %}
{% else %}
{% set custom_field = field %}
		  <div id="custom-field{{ custom_field.custom_field_id }}" class="form-group custom-field{{ custom_field.required ? ' required' : '' }}">
            {% if custom_field.tips %}
			<label class="col-sm-2 control-label"><span data-toggle="tooltip" title="{{ custom_field.tips }}">{{ custom_field.name }}</span></label>
			{% else %}
			<label class="col-sm-2 control-label">{{ custom_field.name }}</label>
			{% endif %} 			            
            <div class="col-sm-10">          
          	{% if custom_field.type  ==  'select' %}
              <select name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control">
                <option value="">{{ text_select }}</option>
                {% for custom_field_value in custom_field['custom_field_value'] %}
                {% if register_custom_field[custom_field['custom_field_id']]  and  custom_field_value.custom_field_value_id  ==  register_custom_field[custom_field['custom_field_id']] %}
                <option value="{{ custom_field_value.custom_field_value_id }}" selected="selected">{{ custom_field_value.name }}</option>
                {% else %}
                <option value="{{ custom_field_value.custom_field_value_id }}">{{ custom_field_value.name }}</option>
                {% endif %}
				{% endfor %}
              </select>                       
          	 {% elseif custom_field.type  ==  'radio' %}
              <div>
                {% for custom_field_value in custom_field['custom_field_value'] %}
                <div class="radio">
                  <label>
                  {% if register_custom_field[custom_field['custom_field_id']]  and  custom_field_value.custom_field_value_id  ==  register_custom_field[custom_field['custom_field_id']] %}                  
                    <input type="radio" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" checked="checked" />                    
                  {% else %}
                    <input type="radio" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ custom_field_value.custom_field_value_id }}" />                    
                  {% endif %}
                  {{ custom_field_value.name }}
                  </label>
              	</div>
                {% endfor %}                
              </div>         
          	 {% elseif custom_field.type  ==  'checkbox' %}
              <div>
                {% for custom_field_value in custom_field['custom_field_value'] %}
                <div class="checkbox">
                 <label>
                  {% if register_custom_field[custom_field['custom_field_id']]  and  custom_field_value.custom_field_value_id in register_custom_field[custom_field['custom_field_id']] %}                 	
                   <input type="checkbox" name="custom_field[{{ custom_field.location}}][{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" checked="checked" />                    
                   {% else %}
                    <input type="checkbox" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}][]" value="{{ custom_field_value.custom_field_value_id }}" />                   
                  {% endif %}
                  {{ custom_field_value.name }}
                  </label>
                  </div> 
                 {% endfor %}                             
                </div>         
          	 {% elseif custom_field.type  ==  'text' %}
              <input type="{{ custom_field.isnumeric?'tel':'text' }}" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ register_custom_field[custom_field['custom_field_id']] ? register_custom_field[custom_field['custom_field_id']] : custom_field.value}}" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control {{ custom_field.isnumeric?'numeric':'' }}" />          
          	 {% elseif custom_field.type  ==  'textarea' %}
              <textarea name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" rows="5" placeholder="{{ custom_field.name }}" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control">{{ register_custom_field[custom_field['custom_field_id']] ? register_custom_field[custom_field['custom_field_id']] : custom_field.value }}</textarea>                     
          	 {% elseif custom_field.type  ==  'file' %}
              <button type="button" id="button-custom-field{{ custom_field.custom_field_id }}" data-loading-text="{{ text_loading }}" class="btn btn-default"><i class="fa fa-upload"></i> {{ button_upload }}</button>
              <input type="hidden" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ register_custom_field[custom_field['custom_field_id']] ? register_custom_field[custom_field['custom_field_id']] : '' }}" />                       
          	 {% elseif custom_field.type  ==  'date' %}
              <div class="input-group date">
                <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ register_custom_field[custom_field['custom_field_id']] ? register_custom_field[custom_field['custom_field_id']] : custom_field.value }}" placeholder="{{ custom_field.name }}" data-date-format="YYYY-MM-DD" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control" />
                <span class="input-group-btn">
                <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
                </span>
               </div>       
          	 {% elseif custom_field.type  ==  'time' %}
              <div class="input-group time">
                <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ register_custom_field[custom_field['custom_field_id']] ? register_custom_field[custom_field['custom_field_id']] : custom_field.value }}" placeholder="{{ custom_field.name }}" data-date-format="HH:mm" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control" />
                <span class="input-group-btn">
                <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
                </span>
               </div>     
          	 {% elseif custom_field.type  ==  'datetime' %}
              <div class="input-group datetime">
                <input type="text" name="custom_field[{{ custom_field.location }}][{{ custom_field.custom_field_id }}]" value="{{ register_custom_field[custom_field['custom_field_id']] ? register_custom_field[custom_field['custom_field_id']] : custom_field.value }}" placeholder="{{ custom_field.name }}" data-date-format="YYYY-MM-DD HH:mm" id="input-custom-field{{ custom_field.custom_field_id }}" class="form-control" />
                <span class="input-group-btn">
                <button type="button" class="btn btn-default"><i class="fa fa-calendar"></i></button>
                </span>
               </div>      
          	{% endif %}
          	{% if error_custom_field[custom_field['custom_field_id']] %}
              <div class="text-danger">{{ error_custom_field[custom_field['custom_field_id']] }}</div>
             {% endif %}
            </div>
          </div>
{% endif %}