{~
    if(!isset(@page.description))
        @page.description = 'Criar/Editar';

    if(!@breadcrumbs)
        if(isset(@form.table))
            @breadcrumbs = array(@form.table => @page.title, @page.description);
        else
            @breadcrumbs = array(@page.title);
    
    @meta.styles.raw.radiofix          = '.radio { margin-top: 2px; }';

    if(!(@flash = flash('error')) && isset(@form.errors) && !empty(@form.errors)) @flash = 'Ocorreu um erro ao salvar o item!<br> verifique os campos para mais detalhes.';
~}
<include href="hwapx/admin/admin/header.html" />
<div class="row">
	{~ 
        if(!isset(@form.width))
			@form.width = 10;
	~}
    <div class="col-lg-{{ @form.width }} col-lg-offset-{{ round((12 - @form.width) / 2) }} col-md-12 col-md-offset-0">
        <!-- Custom tabs (Charts with tabs)-->
        <div class="nav-tabs-custom">
            <!-- Tabs within a box -->
            <ul class="nav nav-tabs pull-right">
                <check if="{{ isset(@form.groups) }}">
                    {~ @form.groups = array_reverse(@form.groups, true); ~}
                    <repeat group="{{ @form.groups }}" key="{{ @groupname }}" value="{{ @group }}" counter="{{ @counter }}">
                        <li class="{{ @counter == count(@form.groups) ? 'active' : '' }}"><a href="#group_{{ @groupname }}" data-toggle="tab">{{ @@group.legend }}</a></li>
                    </repeat>
                </check>
                <li class="pull-left header"><i class="fa fa-pencil"></i> {{ @form.title }}</li>
            </ul>
            <!-- form start -->
            <form id="main_form" disabled>
                <div class="box" style="border:none">
                    <div class="box-body">
                        {~ if(!isset(@form.groups)) @form.groups.main = array('legend' => 'main', 'fields' => @form.fields); ~}
                        <div class="tab-content no-padding">
                            <repeat group="{{ @form.groups }}" key="{{ @groupname }}" value="{{ @group }}" counter="{{ @counter }}">
                                <check if="{{ @group.role | role }}">
                                    <div id="group_{{ @groupname }}" class="tab-pane{{ @counter == count(@form.groups) ? ' active' : '' }}">
                                        <div class="row">
                                            <div class="col-lg-12">
                                                <div class="row">
                                                    <check if="{{ isset(@group.table) }}">
                                                        <true>
                                                            <div class="col-md-12" style="margin-bottom: 10px;">
                                                                {~
                                                                    @_groupdata = (boolean)isset(@group.group);
                                                                    @_table = array(null);
                                                                    if(isset(@form.values[@groupname]))
                                                                        @_table += @form.values[@groupname];
                                                                    //@_table[0] = null;
                                                                    //array_unshift(@_table, null);
                                                                    @_table_row_count = 0;//count(@_table);
                                                                    foreach (@_table as @idx =>@_dummy):
                                                                        @_table_row_count = max(@_table_row_count,@$idx);
                                                                    endforeach;
                                                                    @_showactioncolumn = !isset(@group.allow_insert) || !isset(@group.allow_delete) || @group.allow_insert || @group.allow_delete;
                                                                ~}
                                                                <table class="table table-striped" {{ isset(@group.order) ? 'data-sortfield="'.@group.order.'"' : '' }} id="table_{{ @groupname }}">
                                                                    <thead>
                                                                        <tr>
                                                                            <check if="{{ isset(@group.order) }}">
                                                                                <th style="width: 72px;min-width: 72px;max-width: 72px;">
                                                                                Ordem
                                                                                </th>
                                                                            </check>
                                                                            <repeat group="{{ @group.table }}" key="{{ @fieldname }}" value="{{ @field }}">
                                                                                <th data-fieldname="{{ @fieldname }}">{{ @field.label }}{{ (isset(@field.rules) and in_array('required', @field.rules)) ? ' <span class="text-danger">*</span>' : '' }}</th>
                                                                                <check if="{{ isset(@field.type) && @field.type == 'text' && isset(@field.options) }}">
                                                                                    <datalist id="datalist_{{ @groupname }}[{{ @fieldname }}]">
                                                                                        <repeat group="{{ @field.options }}" key="{{ @option_value }}" value="{{ @option_text }}">
                                                                                            <option value="{{ @option_text }}">{{ @option_value }}</option>
                                                                                        </repeat>
                                                                                    </datalist>
                                                                                </check>
                                                                            </repeat>
                                                                            <check if="{{ @_showactioncolumn }}">
                                                                            <th style="width: 10px">
                                                                                <check if="{{ !isset(@group.allow_insert) || @group.allow_insert }}">
                                                                                    <true>
                                                                                        <a href="javascript:_appendrow('{{ @groupname }}')" class="btn btn-primary btn-md btn-flat"><i class="fa fa-plus"></i></a>
                                                                                    </true>
                                                                                    <false>
                                                                                        <i class="fa fa-bolt"></i>
                                                                                    </false>
                                                                                </check>
                                                                            </th>
                                                                            </check>
                                                                        </tr>
                                                                    </thead>
                                                                    <tbody data-row-count="{{ @_table_row_count }}">
                                                                        <repeat group="{{ @_table }}" key="{{ @c }}" value="{{ @row }}" counter="{{ @ic }}">
                                                                            <check if="{{ @ic != 1 && @_groupdata !== false && @_groupdata !== @row[@group.group] }}">
                                                                                {~ @_groupdata = @row[@group.group] ~}
                                                                                <tr>
                                                                                    <th colspan="{{ count(@group.table) + (isset(@group.order) ? 1 : 0) + (@_showactioncolumn ? 1 : 0) }}">
                                                                                        <h4><strong>{{ @_groupdata }}</strong></h4>
                                                                                    </th>
                                                                                </tr>
                                                                            </check>
                                                                            <tr {{ @ic == 1 ? 'class="dont_post" style="display:none" id="row_'.@groupname.'"' : '' }}>
                                                                                <td data-fieldname="id" style="display:none;">
                                                                                    <input type="hidden" readonly="readonly" value="{{ isset(@row.id) ? @row.id : '' }}">
                                                                                </td>
                                                                                <check if="{{ isset(@group.order) }}">
                                                                                <td data-fieldname="{{ @group.order }}">
                                                                                    <div style="width: 72px;min-width: 72px;max-width: 72px;">
                                                                                        <input type="hidden" readonly="readonly" value="{{ isset(@row[@group.order]) ? @row[@group.order] : '' }}" class="order">
                                                                                        <a href="javascript:void(0);" class="btn btn-default btn-flat btn-md order-prior">
                                                                                            <i class="fa fa-caret-up" style="cursor: pointer;"></i>
                                                                                        </a>
                                                                                        <a href="javascript:void(0);" class="btn btn-default btn-flat btn-md order-next">
                                                                                            <i class="fa fa-caret-down" style="cursor: pointer;"></i>
                                                                                        </a>
                                                                                    </div>
                                                                                </td>
                                                                                </check>
                                                                                <repeat group="{{ @group.table }}" key="{{ @fieldname }}" value="{{ @field }}">
                                                                                    {~ @_value = isset(@row[@fieldname]) ? @row[@fieldname] : (isset(@field.default) ? @field.default : '') ~}
                                                                                    <td data-fieldname="{{ @fieldname }}" style="vertical-align: middle;">
                                                                                        <div class="{{ isset(@form.errors[@groupname][@c][@fieldname]) ? 'form-group has-error' : '' }}">
                                                                                            <switch expr="{{ @field.type }}">
                                                                                                <case value="static">
                                                                                                    <p class="form-control-static">{{ isset(@row[@fieldname]) ? @row[@fieldname] : (isset(@field.default) ? @field.default : '') }}</p>
                                                                                                </case>
                                                                                                <case value="wysiwyg">
                                                                                                    <textarea class="form-control trumbowyg" readonly="readonly" style="height:300px;margin: 0;width: 100%;">{{ isset(@form.values[@fieldname]) ? @row[@fieldname] : (isset(@field.default) ? @field.default : '') }}</textarea>
                                                                                                </case>
                                                                                                <case value="textarea">
                                                                                                    <textarea class="form-control" readonly="readonly" style="height:200px">{{ isset(@row[@fieldname]) ? @row[@fieldname] : (isset(@field.default) ? @field.default : '') }}</textarea>
                                                                                                </case>
                                                                                                <case value="checkbox">
                                                                                                    <check if="{{ isset(@field.options) }}">
                                                                                                        <true>
                                                                                                            <repeat group="{{ @field.options }}" key="{{ @opt }}" value="{{ @lbl }}">
                                                                                                                <div class="checkbox">
                                                                                                                    <label>
                                                                                                                        <input class="" value="{{ @opt }}" type="checkbox" readonly="readonly" {{ (isset(@row[@fieldname]) and in_array(@opt, @row[@fieldname])) ? 'checked' : '' }}/>
                                                                                                                        {{ @lbl }}
                                                                                                                    </label>
                                                                                                                </div>
                                                                                                            </repeat>
                                                                                                        </true>
                                                                                                        <false>
                                                                                                            <div class="checkbox">
                                                                                                                <label>
                                                                                                                    <input value="{{ @field.value }}" type="checkbox" readonly="readonly" {{ (isset(@row[@fieldname]) and (@row[@fieldname] == @field.value)) ? 'checked' : '' }}/>
                                                                                                                    Sim/Não
                                                                                                                </label>
                                                                                                            </div>
                                                                                                        </false>
                                                                                                    </check>
                                                                                                </case>
                                                                                                <case value="radio">
                                                                                                    <div class="radio">
                                                                                                        <repeat group="{{ @field.options }}" key="{{ @opt }}" value="{{ @lbl }}">
                                                                                                                <label class="radio-inline">
                                                                                                                    <input class="" value="{{ @opt }}" type="radio" readonly="readonly" {{ ((isset(@row[@fieldname]) && (@opt == @row[@fieldname])) || (!isset(@form.values[@fieldname]) && isset(@field.default) && (@field.default == @opt))) ? 'checked' : '' }}/>
                                                                                                                    {{ @lbl }}
                                                                                                                </label>
                                                                                                        </repeat>
                                                                                                        <div style="height: 3px"></div>
                                                                                                    </div>
                                                                                                </case>
                                                                                                <case value="dropdown">
                                                                                                    <select class="form-control" readonly="readonly">
                                                                                                        <repeat group="@field.options" key="{{ @key }}" value="{{ @desc }}">
                                                                                                            <option value="{{ @key }}" {{ @key == (isset(@row[@fieldname]) ?
                                                                                                                                                   @row[@fieldname] : (isset(@field.default) ?
                                                                                                                                                                              @field.default : null)) ? ' selected' : '' }}>{{ @desc }}</option>
                                                                                                        </repeat>
                                                                                                    </select>
                                                                                                </case>
                                                                                                <case value="date">
                                                                                                    <div class="input-group date">
                                                                                                        <input class="form-control {{ @field.type }}" value="{{ isset(@row[@fieldname]) ? @row[@fieldname] : (isset(@field.default) ? @field.default : '') }}" type="text" readonly="readonly" data-date-format="{{ @app.date.format2 }}"/>
                                                                                                        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                                                                                                    </div>
                                                                                                </case>
                                                                                                <case value="time">
                                                                                                    <div class="input-group date">
                                                                                                        <input class="form-control {{ @field.type }}" value="{{ isset(@row[@fieldname]) ? @row[@fieldname] : (isset(@field.default) ? @field.default : '') }}" type="text" readonly="readonly" data-date-format="{{ @app.time.format2 }}"/>
                                                                                                        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                                                                                                    </div>
                                                                                                </case>
                                                                                                <case value="datetime">
                                                                                                    <div class="input-group date">
                                                                                                        <input class="form-control {{ @field.type }}" value="{{ isset(@row[@fieldname]) ? @row[@fieldname] : (isset(@field.default) ? @field.default : '') }}" type="text" readonly="readonly" data-date-format="{{ @app.datetime.format2 }}"/>
                                                                                                        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                                                                                                    </div>
                                                                                                </case>
                                                                                                <case value="password">
                                                                                                    <input class="form-control" type="password" readonly="readonly" value="{{ isset(@row[@fieldname]) ? '********' : '' }}" />
                                                                                                </case>
                                                                                                <case value="image">
                                                                                                    <input class="form-control file_image" value="{{ isset(@row[@fieldname]) ? @row[@fieldname] : (isset(@field.default) ? @field.default : '') }}" type="file" readonly="readonly" {{ (isset(@field.multiple) and @field.multiple) ? 'multiple' : '' }} />
                                                                                                    {~
                                                                                                        @__img_tag = isset(@row[@fieldname]) && file_exists(@UPLOADS . @row[@fieldname]) ? "\"<img src='/" . @UPLOADS . @row[@fieldname] . "' class='file-preview-image' alt='Imagem'>\"" : "";
                                                                                                        @meta.scripts.raw['fileinput_'.@fieldname] = 'jQuery(document).ready(function($) { 
                                                                                                                                   $("[name='.@fieldname.']").fileinput({
                                                                                                                                         showUpload: false,
                                                                                                                                         showPreview: false,
                                                                                                                                         overwriteInitial: true,
                                                                                                                                         initialPreview: [
                                                                                                                                            '.@__img_tag.'
                                                                                                                                        ],
                                                                                                                                       });
                                                                                                                                });'; 
                                                                                                    ~}
                                                                                                </case>
                                                                                                <case value="number">
                                                                                                    <input 
                                                                                                        class="form-control text-right"
                                                                                                        value="{{ @_value }}" 
                                                                                                        data-inputmask="'alias': 'numeric', 'groupSeparator': '{{ @app.number.thousands }}', 'radixPoint': '{{ @app.number.radixpoint }}', 'autoGroup': true, 'digits': {{ isset(@field.digits) ? @field.digits : 0 }}, 'digitsOptional': false, 'prefix': '', 'placeholder': '0'"
                                                                                                        type="text"
                                                                                                        readonly="readonly"
                                                                                                    />
                                                                                                </case>
                                                                                                <default>
                                                                                                    <input 
                                                                                                        class="form-control" 
                                                                                                        value="{{ @_value }}"
                                                                                                        type="{{ isset(@field.type) ? @field.type : 'text' }}" 
                                                                                                        {{ isset(@field.mask) ? 'data-inputmask-clearIncomplete="true" data-inputmask-skipOptionalPartCharacter: " " data-inputmask data-inputmask-mask="'.@field.mask.'"' : '' }}
                                                                                                        readonly="readonly"
                                                                                                        {{ isset(@field.type) && @field.type == 'text' && isset(@field.options) ? "list=\"datalist_{@groupname}[@fieldname]\"" : '' }} 
                                                                                                    />
                                                                                                </default>
                                                                                            </switch>
                                                                                            <check if="{{ isset(@form.errors[@groupname][@c][@fieldname]) }}">
                                                                                                <true>
                                                                                                    {*<div class="alert alert-danger" role="alert">
                                                                                                    {{ implode(@form.errors[@groupname][@c][@fieldname], '<br>') }}
                                                                                                    </div>*}
                                                                                                    <p class="help-block">{{ implode(@form.errors[@groupname][@c][@fieldname], ', ') }}</p>
                                                                                                </true>
                                                                                                <false>
                                                                                                    <check if="{{ isset(@form.errors[@groupname][@c]) }}">
                                                                                                    <p class="help-block">&nbsp;</p>
                                                                                                    </check>
                                                                                                </false>
                                                                                            </check>
                                                                                        </div>
                                                                                    </td>
                                                                                </repeat>
                                                                                <check if="{{ !isset(@group.allow_delete) || @group.allow_delete }}">
                                                                                <td style="width: 10px"><a href="javascript:void(0);" onclick="jQuery(this).parent().parent().remove();" class="btn btn-danger btn-md btn-flat"><i class="fa fa-times"></i></a></td>
                                                                                </check>
                                                                            </tr>
                                                                        </repeat>
                                                                    </tbody>
                                                                </table>
                                                            </div>
                                                        </true>
                                                        <false>
                                                            <repeat group="{{ @group.fields }}" key="{{ @fieldname }}" value="{{ @field }}">
																{~
                                                                    @_value = isset(@form.values[@fieldname]) ? @form.values[@fieldname] : (isset(@field.default) ? @field.default : '');
																	if(!isset(@field.width))
																		@field.width = in_array(@field.type, array('textarea', 'wysiwyg')) ? '12' : '6';
																~}
                                                                <div class="col-lg-{{ @field.width }} col-md-{{ @field.width }}">
                                                                    <div class="form-group{{ isset(@form.errors[@fieldname]) ? ' has-error' : '' }}">
                                                                        <label>{{ @field.label }}{{ (isset(@field.rules) and in_array('required', @field.rules)) ? ' <span class="text-danger">*</span>' : '' }}</label>
                                                                        <switch expr="{{ @field.type }}">
                                                                            <case value="static">
                                                                                <p class="form-control-static">{{ @_value }}</p>
                                                                            </case>
                                                                            <case value="wysiwyg">
                                                                                <textarea class="form-control trumbowyg" readonly="readonly" style="height:300px;margin: 0;width: 100%;">{{ isset(@form.values[@fieldname]) ? @form.values[@fieldname] : (isset(@field.default) ? @field.default : '') }}</textarea>
                                                                            </case>
                                                                            <case value="code">
                                                                                <textarea class="form-control" id="codemirror_{{ @fieldname }}" readonly="readonly" style="height:300px;margin: 0;width: 100%;">{{ isset(@form.values[@fieldname]) ? @form.values[@fieldname] : (isset(@field.default) ? @field.default : '') }}</textarea>
                                                                                {~
                                                                                    @meta.scripts.raw['codemirror_'.@fieldname] = 'CodeMirror.fromTextArea(document.getElementById("codemirror_'.@fieldname.'"), '.(isset(@field.options) ? json_encode((object)@field.options) : '{lineNumbers: true}').');';
                                                                                ~}
                                                                                </script>
                                                                            </case>
                                                                            <case value="textarea">
                                                                                <textarea class="form-control" readonly="readonly" style="height:200px">{{ isset(@form.values[@fieldname]) ? @form.values[@fieldname] : (isset(@field.default) ? @field.default : '') }}</textarea>
                                                                            </case>
                                                                            <case value="checkbox">
                                                                                <check if="{{ isset(@field.options) }}">
                                                                                    <true>
                                                                                        <repeat group="{{ @field.options }}" key="{{ @opt }}" value="{{ @lbl }}">
                                                                                            <div class="checkbox">
                                                                                                <label>
                                                                                                    <input class="" value="{{ @opt }}" type="checkbox" readonly="readonly" {{ (isset(@form.values[@fieldname]) and in_array(@opt, @form.values[@fieldname])) ? 'checked' : '' }}/>
                                                                                                    {{ @lbl }}
                                                                                                </label>
                                                                                            </div>
                                                                                        </repeat>
                                                                                    </true>
                                                                                    <false>
                                                                                        <div class="checkbox">
                                                                                            <label>
                                                                                                <input value="{{ @field.value }}" type="checkbox" readonly="readonly" {{ (isset(@form.values[@fieldname]) and (@form.values[@fieldname] == @field.value)) ? 'checked' : '' }}/>
                                                                                                Sim/Não
                                                                                            </label>
                                                                                        </div>
                                                                                    </false>
                                                                                </check>
                                                                            </case>
                                                                            <case value="radio">
                                                                                <div class="radio">
                                                                                    <repeat group="{{ @field.options }}" key="{{ @opt }}" value="{{ @lbl }}">
                                                                                            <label class="radio-inline">
                                                                                                <input class="" value="{{ @opt }}" type="radio" readonly="readonly" {{ ((isset(@form.values[@fieldname]) && (@opt == @form.values[@fieldname])) || (!isset(@form.values[@fieldname]) && isset(@field.default) && (@field.default == @opt))) ? 'checked' : '' }}/>
                                                                                                {{ @lbl }}
                                                                                            </label>
                                                                                    </repeat>
                                                                                    <div style="height: 3px"></div>
                                                                                </div>
                                                                            </case>
                                                                            <case value="dropdown">
                                                                                <select class="form-control" readonly="readonly">
                                                                                    <repeat group="@field.options" key="{{ @key }}" value="{{ @desc }}">
                                                                                        <option value="{{ @key }}" {{ @key == (isset(@form.values[@fieldname]) ?
                                                                                                                               @form.values[@fieldname] : (isset(@field.default) ?
                                                                                                                                                          @field.default : null)) ? ' selected' : '' }}>{{ @desc }}</option>
                                                                                    </repeat>
                                                                                </select>
                                                                            </case>
                                                                            <case value="date">
                                                                                <div class="input-group date">
                                                                                    <input class="form-control {{ @field.type }}" value="{{ isset(@form.values[@fieldname]) ? @form.values[@fieldname] : (isset(@field.default) ? @field.default : '') }}" type="text" readonly="readonly" data-date-format="{{ @app.date.format2 }}" />
                                                                                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                                                                                </div>
                                                                            </case>
                                                                            <case value="time">
                                                                                <div class="input-group date">
                                                                                    <input class="form-control {{ @field.type }}" value="{{ isset(@form.values[@fieldname]) ? @form.values[@fieldname] : (isset(@field.default) ? @field.default : '') }}" type="text" readonly="readonly" data-date-format="{{ @app.time.format2 }}"/>
                                                                                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                                                                                </div>
                                                                            </case>
                                                                            <case value="datetime2">
                                                                                <div class="input-group date">
                                                                                    <input class="form-control {{ @field.type }}" value="{{ isset(@form.values[@fieldname]) ? @form.values[@fieldname] : (isset(@field.default) ? @field.default : '') }}" type="text" readonly="readonly" data-date-format="{{ @app.datetime.format2 }}"/>
                                                                                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                                                                                </div>
                                                                            </case>
                                                                            <case value="datetime">
                                                                                <div class="input-group date">
                                                                                    <input class="form-control {{ @field.type }}" value="{{ isset(@form.values[@fieldname]) ? @form.values[@fieldname] : (isset(@field.default) ? @field.default : '') }}" type="text" readonly="readonly" data-date-format="{{ @app.datetime.format2 }}"/>
                                                                                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
                                                                                </div>
                                                                            </case>
                                                                            <case value="password">
                                                                                <input class="form-control" type="password" readonly="readonly" value="{{ isset(@form.values[@fieldname]) ? '********' : '' }}" />
                                                                            </case>
                                                                            <case value="image">
                                                                                <input class="form-control file_image" value="{{ isset(@form.values[@fieldname]) ? @form.values[@fieldname] : (isset(@field.default) ? @field.default : '') }}" type="file" readonly="readonly" {{ (isset(@field.multiple) and @field.multiple) ? 'multiple' : '' }} />
                                                                                {~
                                                                                    @__img_tag = isset(@form.values[@fieldname]) && file_exists(@UPLOADS . @form.values[@fieldname]) ? "\"<img src='/" . @UPLOADS . @form.values[@fieldname] . "' class='file-preview-image' alt='Imagem'>\"" : "";
                                                                                    @meta.scripts.raw['fileinput_'.@fieldname] = 'jQuery(document).ready(function($) { 
                                                                                                               $("[name='.@fieldname.']").fileinput({
                                                                                                                     showUpload: false,
                                                                                                                     overwriteInitial: true,
                                                                                                                     initialPreview: [
                                                                                                                        '.@__img_tag.'
                                                                                                                    ],
                                                                                                                   });
                                                                                                            });'; 
                                                                                ~}
                                                                            </case>
                                                                            <case value="number">
                                                                                <input 
                                                                                    class="form-control text-right"
                                                                                    value="{{ @_value }}" 
                                                                                    data-inputmask="'alias': 'numeric', 'groupSeparator': '{{ @app.number.thousands }}', 'radixPoint': '{{ @app.number.radixpoint }}', 'autoGroup': true, 'digits': {{ isset(@field.digits) ? @field.digits : 0 }}, 'digitsOptional': false, 'prefix': '', 'placeholder': '0'"
                                                                                    type="text"
                                                                                    readonly="readonly"
                                                                                />
                                                                            </case>
                                                                            <default>
                                                                                <check if="{{ isset(@field.type) && @field.type == 'text' && isset(@field.options) }}">
                                                                                    <datalist id="datalist_{{ @fieldname }}">
                                                                                        <repeat group="{{ @field.options }}" key="{{ @option_value }}" value="{{ @option_text }}">
                                                                                            <option value="{{ @option_text }}">{{ @option_value }}</option>
                                                                                        </repeat>
                                                                                    </datalist>
                                                                                </check>
                                                                                <input 
                                                                                    class="form-control"
                                                                                    value="{{ @_value }}" 
                                                                                    type="{{ isset(@field.type) ? @field.type : 'text' }}" 
                                                                                    {{ isset(@field.mask) ? 'data-inputmask-clearIncomplete="true" data-inputmask-skipOptionalPartCharacter: " " data-inputmask data-inputmask-mask="'.@field.mask.'"' : '' }}
                                                                                    {{ isset(@field.type) && @field.type == 'text' && isset(@field.options) ? 'list="datalist_'.@fieldname.'"' : '' }} 
                                                                                    readonly="readonly" />
                                                                            </default>
                                                                        </switch>
                                                                    </div>
                                                                </div>
                                                            </repeat>
                                                        </false>
                                                    </check>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </check>
                            </repeat>
                        </div>
                        <a href="{{ isset(@form.table) ? @ALIASES[@form.table] : @ALIASES.admin_dashboard }}" class="btn btn-primary btn-flat">Voltar</a>
                        <check if="{{ isset(@form.actions) }}">
                            <div class="pull-right">
                            <repeat group="{{ @form.actions }}" value="{{ @action }}" counter="{{ @counter }}">
                                <check if="{{ @action.role | role }}">
                                    <true>
                                        <check if="{{ isset(@action.params) }}">
                                            <repeat group="{{ @action.params }}" key="{{ @param }}" value="{{ @field }}">
                                                {~ F3::set('PARAMS.'.@param, @row[@field]) ~}
                                            </repeat>
                                        </check>
                                        <check if="{{ @counter < @app.table.maxactions or count(@form.actions) <= @app.table.maxactions }}">
                                            <true>
                                                <a href="{{ isset(@ALIASES[@action.route]) ? F3::build(@ALIASES[@action.route]) : @action.route }}" class="btn {{ isset(@action.class) ? @action.class : 'btn-default' }} btn-flat" onclick="{{ (isset(@action.confirm) and @action.confirm) ? 'return confirm(\''.addslashes(is_string(@action.confirm) ? @action.confirm : 'Confirma esta ação?').'\');' : '' }}">{{ @action.description }}</a>
                                            </true>
                                            <false>
                                                <check if="{{ @counter == @app.table.maxactions }}">
                                                    <div class="btn-group">
                                                        <button type="button" class="btn btn-default btn-flat dropdown-toggle" data-toggle="dropdown">
                                                            Mais Ações
                                                            <span class="caret"></span>
                                                        </button>
                                                        <ul class="dropdown-menu pull-right" role="menu" style="top: auto; bottom: 36px;">
                                                </check>
                                                    <li>
                                                        <check if="{{ is_array(@action) }}">
                                                            <true>
                                                                <a href="{{ isset(@ALIASES[@action.route]) ? F3::build(F3::alias(@action.route)) : @action.route }}" onclick="{{ (isset(@action.confirm) and @action.confirm) ? 'return confirm(\''.addslashes(is_string(@action.confirm) ? @action.confirm : 'Confirma esta ação?').'\');' : '' }}">{{ @action.description }}</a>
                                                            </true>
                                                            <false>
                                                                <li class="divider"></li>
                                                            </false>
                                                        </check>
                                                    </li>
                                                <check if="{{ @counter == count(@form.actions) }}">
                                                        </ul>
                                                    </div>
                                                </check>
                                            </false>
                                        </check>
                                    </true>
                                    <false>
                                        {~ @counter-- ~}
                                    </false>
                                </check>
                            </repeat>
                            </div>
                        </check>
                    </div>
                </div>
            </form>
        </div><!-- /.nav-tabs-custom -->
    </div>
</div>   <!-- /.row -->
<include href="hwapx/admin/admin/footer.html" />