<!-- Repeater -->
{{ if (field.containerClass) { }}<div class="{{= field.containerClass }}">{{ } }}
<div id="{{= field.id }}" class="row" data-alias="{{= field.alias }}" data-min="{{= field.min }}" data-max="{{= field.max }}">
    {{ if (field.label) { }}<div class="col-12">
        <label class="{{= field.labelClass }}" for="{{= field.id }}">
            {{= field.label }}
        </label>
    </div>{{ } }}{{ if (field.helpText && field.helpTextPlacement === "above") { }}
    <p class="form-text">{{= field.helpText }}</p>{{ } }}
    <div class="col-12" data-repeater-list="{{= field.id }}">
        <div class="row" data-repeater-item>
            <div class="col-10">
                <div class="row">{{ _.each(field.nestedFields, function(nf, i) { }}
                    {{ if (nf.inputType === "hidden") { }}
                        <div>
                            <input type="{{= nf.inputType }}" id="{{= field.id+'_'+i }}" name="{{= field.id+'_'+i }}" data-repeater-id="{{= field.id }}" data-label="{{- nf.label.replace(/(<([^>]+)>)/ig,'') }}"{{ if(nf.alias) { }} data-alias="{{= nf.alias+'_'+i }}"{{ } }}{{ if (nf.predefinedValue) { }} value="{{= nf.predefinedValue }}"{{ } }}{{ if(nf.required){ }} required{{ } }}{{ if (nf.unique) { }} data-unique="{{= nf.unique }}"{{ } }}{{ _.each(nf.customAttributes, function(attribute, i){ var attrs = attribute.split("|"); var attr = attrs[0]; var val = (attrs.length > 1) ? attrs[1] : attrs[0]; }}{{ if (attr) { }} {{- attr }}="{{- val }}"{{ } }}{{ }) }}>
                        </div>
                    {{ } else { }}
                        <div class="{{= nf.containerClass }}">
                            <div class="{{ if (layout == 'form-horizontal') { }}row {{ } }}form-group{{ if (nf.required) { }} required-control{{ } }}">
                                {{ if (nf.label) { }}<label class="{{ if (layout == 'form-horizontal') { }}col-form-label col-3{{ } }} {{= nf.labelClass }}" for="{{= field.id+'_'+i }}">{{= nf.label }}</label>{{ } }} {{ if (nf.inputType === "select") { }}
                                {{ if (nf.prepend || nf.append) { }}<div class="{{= nf.inputGroupClass }}">{{ } }}
                                {{ if (nf.prepend) { }}<span class="input-group-text">{{= nf.prepend }}</span>{{ } }}
                                <select id="{{= field.id+'_'+i }}" name="{{= field.id+'_'+i }}" data-repeater-id="{{= field.id }}" data-label="{{- nf.label.replace(/(<([^>]+)>)/ig,'') }}"{{ if (nf.cssClass) { }} class="{{= nf.cssClass }}"{{ } }}{{ if(nf.alias) { }} data-alias="{{= nf.alias+'_'+i }}"{{ } }}{{ if (nf.required) { }} required{{ } }}{{ if (nf.readOnly) { }} readOnly{{ } }}{{ if (nf.disabled) { }} disabled{{ } }}{{ if (nf.multiple) { }} multiple{{ } }}{{ _.each(nf.customAttributes, function(attribute, i){ var attrs = attribute.split("|"); var attr = attrs[0]; var val = (attrs.length > 1) ? attrs[1] : attrs[0]; }}{{ if (attr) { }} {{- attr }}="{{- val }}"{{ } }}{{ }) }}>{{ if(nf.placeholder) { }}
                                    <option value="" disabled selected>{{= nf.placeholder }}</option>{{ } }}{{ var lastIndex = nf.options.length - 1; var groups = []; _.each(nf.options, function(option, index) { var items = option.split("|"); var last = items[items.length-1]; var selected = (last==="selected"||last==="select"|last==="check"); var option = items[0]; var value = ((items.length == 3 && selected) || (items.length == 2) && !selected) ? items[1] : items[0]; }}
                                    {{ if (typeof value === 'string' && (value.substring(0, 2) === '[[') && (value.substring(value.length-2, value.length) === ']]')) { }} {{ if (groups.length !== 0) { }}</optgroup>{{ } }}<optgroup label="{{= value.substring(2, value.length - 2) }}">{{ groups.push(index); } else { }} <option value="{{= value }}" {{ if (selected) { }} selected{{ } }}>{{= option }}</option> {{ } }}   {{ if (lastIndex === index && groups.length > 0) { }}</optgroup>{{ } }} {{ }); }}
                                </select>
                                {{ if (nf.append) { }}<span class="input-group-text">{{= nf.append }}</span>{{ } }}
                                {{ if (nf.prepend || nf.append) { }}</div>{{ } }}
                                {{ } else if (nf.inputType === "radio") { }} {{ _.each(nf.options, function(radio, index){ var items = radio.split("|"); var last = items[items.length-1]; var checked = (last==="selected"||last==="select"|last==="check"); radio = items[0]; var value = ((items.length >= 3) || (items.length == 2) && !checked) ? items[1] : items[0]; var figure = ((items.length >= 4) || (items.length == 3 && !checked)) ? items[2] : false; }}
                                <div{{ if (nf.cssClass) { }} class="{{= nf.cssClass }}{{ if (figure) { }} form-check-image{{ } }}{{ if (nf.inline) { }} form-check-inline{{ } }}{{ if (nf.asButton) { }} form-check-btn{{ } }}"{{ } }}{{ if(nf.disabled) { }} disabled{{ } }}>
                                    <input type="radio" name="{{= field.id+'_'+i }}" id="{{= field.id+'_'+i+'_'+index }}" class="form-check-input{{ if (nf.asButton) { }} btn-check{{ } }}" value="{{- value.replace(/(<([^>]+)>)/ig,'') }}" data-alias="{{= nf.alias }}" data-repeater-id="{{= field.id }}"{{ if(nf.required){ }} data-required="true"{{ } }}{{ if(nf.readOnly) { }}readOnly {{ } }}{{ if(nf.disabled) {}}disabled {{ } }} {{ if(checked) { }}checked {{ } }}{{ _.each(nf.customAttributes, function(attribute, a_i){ var attrs = attribute.split("|"); var attr = attrs[0]; var val = (attrs.length > 1) ? attrs[1] : attrs[0]; }}{{ if (attr) { }} {{- attr }}="{{- val }}"{{ } }}{{ }) }}>
                                    <label for="{{= field.id+'_'+i+'_'+index }}" class="form-check-label{{ if (nf.asButton) { }} btn btn-default{{ } }}">{{ if(figure) { }}
                                        <span class="form-check-figure">{{ if (figure.indexOf("http") == 0) { }}<img src="{{= figure }}" />{{ } else { }}<span class="{{= figure }}"> </span>{{ } }}</span>{{ } }}
                                        <span class="form-check-text">{{= radio }}</span>
                                    </label>
                                </div>{{ }); }} {{ } else if (nf.inputType === "checkbox") { }} {{ _.each(nf.options, function(checkbox, index){ var items = checkbox.split("|"); var last = items[items.length-1]; var checked = (last==="selected"||last==="select"|last==="check"); checkbox = items[0]; var value = ((items.length >= 3) || (items.length == 2) && !checked) ? items[1] : items[0]; var figure = ((items.length >= 4) || (items.length == 3 && !checked)) ? items[2] : false; }}
                                <div{{ if (nf.cssClass) { }} class="{{= nf.cssClass }}{{ if (figure) { }} form-check-image{{ } }}{{ if (nf.inline) { }} form-check-inline{{ } }}{{ if (nf.asButton) { }} form-check-btn{{ } }}"{{ } }}{{ if(nf.disabled) { }} disabled{{ } }}>
                                    <input type="checkbox" name="{{= field.id+'_'+i }}" id="{{= field.id+'_'+i+'_'+index }}" class="form-check-input{{ if (nf.asButton) { }} btn-check{{ } }}" value="{{- value.replace(/(<([^>]+)>)/ig,'') }}" data-alias="{{= nf.alias }}" data-repeater-id="{{= field.id }}"{{ if(nf.required){ }} data-required="true"{{ } }}{{ if(nf.readOnly) { }} readOnly{{ } }}{{ if(nf.disabled) {}} disabled{{ } }} {{ if(checked) { }} checked{{ } }}{{ _.each(nf.customAttributes, function(attribute, i){ var attrs = attribute.split("|"); var attr = attrs[0]; var val = (attrs.length > 1) ? attrs[1] : attrs[0]; }}{{ if (attr) { }} {{- attr }}="{{- val }}"{{ } }}{{ }) }}>
                                    <label for="{{= field.id+'_'+i+'_'+index }}" class="form-check-label{{ if (nf.asButton) { }} btn btn-default{{ } }}">{{ if(figure) { }}
                                        <span class="form-check-figure">{{ if (figure.indexOf("http") == 0) { }}<img src="{{= figure }}" />{{ } else { }}<span class="{{= figure }}"> </span>{{ } }}</span>{{ } }}
                                        <span class="form-check-text">{{= checkbox }}</span>
                                    </label>
                                </div>{{ }); }} {{ } else if (nf.inputType === "textarea") { }}
                                {{ if (nf.prepend || nf.append) { }}<div class="{{= nf.inputGroupClass }}">{{ } }}
                                {{ if (nf.prepend) { }}<span class="input-group-text">{{= nf.prepend }}</span>{{ } }}
                                <textarea id="{{= field.id+'_'+i }}" name="{{= field.id+'_'+i }}" data-repeater-id="{{= field.id }}" data-label="{{- nf.label.replace(/(<([^>]+)>)/ig,'') }}" rows="{{= nf.fieldSize }}"{{ if(nf.alias) { }} data-alias="{{= nf.alias+'_'+i }}"{{ } }}{{ if (nf.minlength) { }} minlength="{{= nf.minlength }}"{{ } }}{{ if (nf.maxlength) { }} maxlength="{{= nf.maxlength }}"{{ } }}{{ if (nf.cssClass) { }} class="{{= nf.cssClass }}"{{ } }}{{ if (nf.placeholder) { }}placeholder="{{= nf.placeholder }}" {{ } }}{{ if(nf.required){ }}required {{ } }}{{ if (nf.unique) { }} data-unique="{{= nf.unique }}"{{ } }}{{ if(nf.readOnly) { }} readOnly{{ } }}{{ if(nf.disabled) { }} disabled{{ } }}{{ _.each(nf.customAttributes, function(attribute, i){ var attrs = attribute.split("|"); var attr = attrs[0]; var val = (attrs.length > 1) ? attrs[1] : attrs[0]; }}{{ if (attr) { }} {{- attr }}="{{- val }}"{{ } }}{{ }) }}>{{ if (nf.predefinedValue) { }}{{= nf.predefinedValue }}{{ } }}</textarea>
                                {{ if (nf.append) { }}<span class="input-group-text">{{= nf.append }}</span>{{ } }}
                                {{ if (nf.prepend || nf.append) { }}</div>{{ } }}
                                {{ } else if (nf.inputType === "number") { }}
                                {{ if (nf.prepend || nf.append) { }}<div class="{{= nf.inputGroupClass }}">{{ } }}
                                {{ if (nf.prepend) { }}<span class="input-group-text">{{= nf.prepend }}</span>{{ } }}
                                <input type="{{= nf.inputType }}" id="{{= field.id+'_'+i }}" name="{{= field.id+'_'+i }}" data-repeater-id="{{= field.id }}" data-label="{{- nf.label.replace(/(<([^>]+)>)/ig,'') }}"{{ if(nf.alias) { }} data-alias="{{= nf.alias+'_'+i }}"{{ } }}{{ if (nf.predefinedValue) { }} value="{{= nf.predefinedValue }}"{{ } }}{{ if (nf.cssClass) { }} class="{{= nf.cssClass }}"{{ } }}{{ if (nf.min) { }} min="{{= nf.min }}"{{ } }}{{ if (nf.max) { }} max="{{= nf.max }}"{{ } }}{{ if (nf.step) { }} step="{{= nf.step }}"{{ } }}{{ if (nf.integerPattern) { }} data-integer-pattern="{{= nf.integerPattern }}"{{ } }}{{ if (nf.numberPattern) { }} data-number-pattern="{{= nf.numberPattern }}"{{ } }}{{ if (nf.placeholder) { }} placeholder="{{- nf.placeholder }}"{{ } }}{{ if(nf.required){ }} required{{ } }}{{ if (nf.unique) { }} data-unique="{{= nf.unique }}"{{ } }}{{ if(nf.readOnly) { }} readOnly{{ } }}{{ if(nf.disabled) { }} disabled{{ } }}{{ _.each(nf.customAttributes, function(attribute, i){ var attrs = attribute.split("|"); var attr = attrs[0]; var val = (attrs.length > 1) ? attrs[1] : attrs[0]; }}{{ if (attr) { }} {{- attr }}="{{- val }}"{{ } }}{{ }) }}>
                                {{ if (nf.append) { }}<span class="input-group-text">{{= nf.append }}</span>{{ } }}
                                {{ if (nf.prepend || nf.append) { }}</div>{{ } }}
                                {{ } else if (nf.inputType === "date") { }}
                                {{ if (nf.prepend || nf.append) { }}<div class="{{= nf.inputGroupClass }}">{{ } }}
                                {{ if (nf.prepend) { }}<span class="input-group-text">{{= nf.prepend }}</span>{{ } }}
                                <input type="{{= nf.inputType }}" id="{{= field.id+'_'+i }}" name="{{= field.id+'_'+i }}" data-repeater-id="{{= field.id }}" data-label="{{- nf.label.replace(/(<([^>]+)>)/ig,'') }}"{{ if(nf.alias) { }} data-alias="{{= nf.alias+'_'+i }}"{{ } }}{{ if (nf.predefinedValue) { }} value="{{= nf.predefinedValue }}"{{ } }}{{ if (nf.cssClass) { }} class="{{= nf.cssClass }}"{{ } }}{{ if (nf.min) { }} min="{{= nf.min }}"{{ } }}{{ if (nf.max) { }} max="{{= nf.max }}"{{ } }}{{ if (nf.step) { }} step="{{= nf.step }}"{{ } }}{{ if (nf.placeholder) { }} placeholder="{{- nf.placeholder }}"{{ } }}{{ if(nf.required){ }} required{{ } }}{{ if (nf.unique) { }} data-unique="{{= nf.unique }}"{{ } }}{{ if(nf.readOnly) { }} readOnly{{ } }}{{ if(nf.disabled) { }} disabled{{ } }}{{ _.each(nf.customAttributes, function(attribute, i){ var attrs = attribute.split("|"); var attr = attrs[0]; var val = (attrs.length > 1) ? attrs[1] : attrs[0]; }}{{ if (attr) { }} {{- attr }}="{{- val }}"{{ } }}{{ }) }}>
                                {{ if (nf.append) { }}<span class="input-group-text">{{= nf.append }}</span>{{ } }}
                                {{ if (nf.prepend || nf.append) { }}</div>{{ } }}
                                {{ } else { }}
                                {{ if (nf.prepend || nf.append) { }}<div class="{{= nf.inputGroupClass }}">{{ } }}
                                {{ if (nf.prepend) { }}<span class="input-group-text">{{= nf.prepend }}</span>{{ } }}
                                <input type="{{= nf.inputType }}" id="{{= field.id+'_'+i }}" name="{{= field.id+'_'+i }}" data-repeater-id="{{= field.id }}" data-label="{{- nf.label.replace(/(<([^>]+)>)/ig,'') }}"{{ if(nf.alias) { }} data-alias="{{= nf.alias+'_'+i }}"{{ } }}{{ if (nf.predefinedValue) { }} value="{{= nf.predefinedValue }}"{{ } }}{{ if (nf.minlength) { }} minlength="{{= nf.minlength }}"{{ } }}{{ if (nf.maxlength) { }} maxlength="{{= nf.maxlength }}"{{ } }}{{ if (nf.cssClass) { }} class="{{= nf.cssClass }}"{{ } }}{{ if (nf.min) { }} min="{{= nf.min }}"{{ } }}{{ if (nf.max) { }} max="{{= nf.max }}"{{ } }}{{ if (nf.step) { }} step="{{= nf.step }}"{{ } }}{{ if (nf.pattern) { }} pattern="{{= nf.pattern }}"{{ } }}{{ if (nf.placeholder) { }} placeholder="{{- nf.placeholder }}"{{ } }}{{ if(nf.required){ }} required{{ } }}{{ if (nf.unique) { }} data-unique="{{= nf.unique }}"{{ } }}{{ if(nf.readOnly) { }} readOnly{{ } }}{{ if(nf.disabled) { }} disabled{{ } }}{{ _.each(nf.customAttributes, function(attribute, i){ var attrs = attribute.split("|"); var attr = attrs[0]; var val = (attrs.length > 1) ? attrs[1] : attrs[0]; }}{{ if (attr) { }} {{- attr }}="{{- val }}"{{ } }}{{ }) }}>
                                {{ if (nf.append) { }}<span class="input-group-text">{{= nf.append }}</span>{{ } }}
                                {{ if (nf.prepend || nf.append) { }}</div>{{ } }}
                                {{ } }}
                            </div>
                        </div>
                    {{ } }}
                {{ }) }}</div>
            </div>
            <div class="col-2">
                <div class="form-group">
                    <button type="button" class="{{= field.removeButtonClass }}" data-exclude="true" data-repeater-delete>
                        {{= field.removeButtonText }}
                    </button>
                </div>
            </div>
        </div>
    </div>
    <div class="col-12">
        <div class="form-group">
            <button type="button" class="{{= field.addButtonClass }}" data-exclude="true" data-repeater-create>
                {{= field.addButtonText }}
            </button>
        </div>
    </div>{{ if (field.helpText && field.helpTextPlacement === "below") { }}
    <p class="form-text">{{= field.helpText }}</p>{{ } }}
</div>
{{ if (field.containerClass) { }}</div>{{ } }}