{{csrf_token()}}

@modelBinding($this->model, $this->isCreatePage)

@foreach($this->fields as $field)
    @if($field->name == 'id')
        @if($field->value)
            <input type="hidden" name="id" value="{{$field->value}}" />
        @endif
    @elseif(($this->isCreatePage && $field->showInCreatePage) || (!$this->isCreatePage && $field->showInUpdatePage))
        <div class="row form-group">
            @if($field->displayName)
                <div class="col-md-12 form-layout-label">
                    <label>{{$field->displayName}}</label>
                    {{$field->required ? '<span class="required-star">(*)</span>' : ''}}
                </div>
            @endif

            <?php if(isset($field->customLayout)) {
 echo $field->customLayout;
 }
 else {
 ?>

            <div class="{{empty($field->extensionOption['layout-column']) ? 'col-sm-12 col-md-8' : $field->extensionOption['layout-column'] }}">
                @inputFor($field->name, ['class' => ($field->type == \FIELD_DATA_TYPE::BOOLEAN || $field->type == \FIELD_DATA_TYPE::RADIO_LIST || $field->type == \FIELD_DATA_TYPE::CHECKBOX_LIST ? '' : 'form-control'), 'error' => $field->error, 'default' => $field->defaultValue ], $field->extensionOption, $field->value)
            </div>
            
            @if($field->error)
                <div class="col-sm-12 col-md-4"><span class="error">{{$field->error}}</span></div>
            @endif

        <?php }
 ?>
            
        </div>
    @endif
@endforeach

<br>
<input type='submit' class='btn btn-primary' value="@lang('lang.save')" />
&nbsp;
<a class='btn btn-default' href="{{isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $this->backUrl}}">@lang('lang.back')</a>

<style>

.form-layout-desc {
    color: #666;
    margin-top: 5px;
    display: block;
    font-size: 12px;
}
.form-group span.error {
    color: #bf1010;
    font-size: 12px;
}
.form-group .form-control.error {
    border-color: #ff6b6b;
}
</style>