<div id="custom-modal" class="modal-demo">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" onclick="Custombox.close();">×</button>
                <h4 class="modal-title">Edition : {{$model->getTitle()}}</h4>
            </div>
            <div class="modal-body">
                <div class="">
                    <form method="POST" action="{{url(Request::path())}}" enctype="multipart/form-data" class="form-horizontal form-label-left input_mask">
                        {{ csrf_field() }}
                        <input type="hidden" value="0" id="_id" name="_id">
                        <?php
                            $i=0;
                        foreach($columns as $name) {

                        $div_class='col-md-12';
                        $title = $titles[$i];
                        ?>

                        @include('inc.cruds.inc.form_content')

                        <?php $i++;} ?>

                        <div id="other_model">

                        </div>


                        <div class="modal-footer">
                            <button type="button" class="btn btn-sm btn-default waves-effect" onclick="Custombox.close();">Annuler</button>
                            <button type="submit" class="btn btn-sm btn-success waves-effect waves-light">Enregistrer</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>


<div style="display: none" id="other_model_temp">
    @if(count($model->getOtherModels())!=0)
        @foreach($model->getOtherModels() as $modelOther)
            <h4 class="m-t-0 header-title col-md-12 sub-title"><b>{{$modelOther->getTitle()}}</b></h4>
            <?php
            $i=0;
            $modelOther_columns = array_keys($modelOther->getFields());
            foreach($modelOther_columns as $name) {
            $str = substr($model->getTable(), 0,strlen($model->getTable())-1);
            if($name!= $str && !in_array($name,$columns)){
            $div_class='col-md-6';
            $modelOther_titles = array_values($modelOther->getFields());
            $title = $modelOther_titles[$i];
            ?>

            @if(!in_array($name,$modelOther->getFieldsHiddens()))
                @if(in_array($name,$modelOther->getDates()))
                    @include('inc.cruds.input_date')
                @elseif(in_array($name,$modelOther->getDatetimes()))
                    @include('inc.cruds.input_date_time')
                @elseif(in_array($name,$modelOther->getDatesRange()))
                    @include('inc.cruds.input_date_range')
                @elseif(in_array($name,$modelOther->getDatetimesRange()))
                    @include('inc.cruds.input_date_time_range')
                @elseif(in_array($name,$modelOther->getImages()))
                    @include('inc.cruds.input_image')
                @elseif(in_array($name,$modelOther->getTimes()))
                    @include('inc.cruds.input_time')
                @elseif(in_array($name,$modelOther->getLongTexts()))
                    @include('inc.cruds.input_texte_area')
                @elseif(in_array($name,$modelOther->getNumbers()))
                    @include('inc.cruds.input_number',['min'=>0,'max'=>999999999999])
                @elseif(in_array($name,$modelOther->getEmails()))
                    @include('inc.cruds.input_email')
                @elseif(in_array($name,$modelOther->getTelephones()))
                    @include('inc.cruds.input_telephone')
                @elseif(in_array($name,array_keys($modelOther->getBelongsTo())))
                    @include('inc.cruds.select_from_model',['column_name'=>$modelOther->getBelongsTo()[$name]])
                @elseif(in_array($name,array_keys($modelOther->getSelects())))
                    @include('inc.cruds.select_from_array',['array'=>$modelOther->getSelects()[$name]])
                @elseif(in_array($name,$modelOther->getPasswords()))
                    @include('inc.cruds.input_password')
                @elseif(in_array($name,$modelOther->getFiles()))
                    @include('inc.cruds.input_file')
                @else
                    @include('inc.cruds.input_texte')
                @endif
            @endif

            <?php  }$i++;} ?>
        @endforeach
    @endif
</div>

