<template name="dialogForm">
    <div id="{{this.id}}" class="modal fade {{this.class}}" tabindex="-1" role="dialog">
        <div class="modal-dialog {{this.dialogClass}}" role="document">
            {{#form class=(concat 'modal-content ' this.formClass) hideValidationBox=true
                api=(extend instance.api instance.data.api) schema=this.schema
            }}
                {{#if or this.title (hasSection 'dialogHeader')}}
                    {{>dialogHeader this}}
                {{/if}}
                <div class="modal-body">
                    <div class="messages">
                        {{#each message in this.messages}}
                            <div class="message">{{{message}}}</div>
                        {{else}}
                            {{#if isError}}
                                {{>pageError (extend this error=this.details)}}
                            {{else}}
                                {{#let message=(choose this.bodyText this.reason this.message (valueIf UI.contentBlock '' 'An error has ocurred.' ))}}
                                    <div class="message">{{message}}</div>
                                {{/let}}
                            {{/if}}
                        {{/each}}
                    </div>
                    {{>UI.contentBlock}}
                </div>
                <div class="modal-footer">
                    {{>section 'dialogFooter'}}
                    {{#unless this.hideCancel}}
                        {{#button action='cancel'
                            disabled=this.cancelDisabled
                            class=(concat 'btn btn-cancel ' (choose this.cancelClass 'btn-secondary'))
                            tagAttributes=(extend this.tagAttributes data-dismiss='modal')
                        }}{{choose this.cancelLabel 'Cancel'}}{{/button}}
                    {{/unless}}
                    {{#unless this.hideConfirm}}
                        {{#button action='confirm'
                            disabled=this.confirmDisabled
                            class=(concat 'btn btn-confirm ' (choose this.confirmClass 'btn-primary'))
                        }}{{choose this.confirmLabel 'Confirm'}}{{/button}}
                    {{/unless}}
                </div>
            {{/form}}
        </div>
    </div>
</template>
