--- /dev/null
+<!-- select from array -->
+<div @include('crud::inc.field_wrapper_attributes') >
+ <label>{!! $field['label'] !!}</label>
+ @include('crud::inc.field_translatable_icon')
+ <select
+ id="cms_template"
+ name="{{ $field['name'] }}@if (isset($field['allows_multiple']) && $field['allows_multiple']==true)[]@endif"
+ @include('crud::inc.field_attributes')
+ @if (isset($field['allows_multiple']) && $field['allows_multiple']==true)multiple @endif
+ >
+
+ @if (isset($field['allows_null']) && $field['allows_null']==true)
+ <option value="">-</option>
+ @endif
+
+ @if (count($field['options']))
+ @foreach ($field['options'] as $key => $value)
+ @if((old(square_brackets_to_dots($field['name'])) && (
+ $key == old(square_brackets_to_dots($field['name'])) ||
+ (is_array(old(square_brackets_to_dots($field['name']))) &&
+ in_array($key, old(square_brackets_to_dots($field['name'])))))) ||
+ (null === old(square_brackets_to_dots($field['name'])) &&
+ ((isset($field['value']) && (
+ $key == $field['value'] || (
+ is_array($field['value']) &&
+ in_array($key, $field['value'])
+ )
+ )) ||
+ (isset($field['default']) &&
+ ($key == $field['default'] || (
+ is_array($field['default']) &&
+ in_array($key, $field['default'])
+ )
+ )
+ ))
+ ))
+ <option value="{{ $key }}" selected>{{ $value }}</option>
+ @else
+ <option value="{{ $key }}">{{ $value }}</option>
+ @endif
+ @endforeach
+ @endif
+ </select>
+
+ {{-- HINT --}}
+ @if (isset($field['hint']))
+ <p class="help-block">{!! $field['hint'] !!}</p>
+ @endif
+</div>
+@if ($crud->checkIfFieldIsFirstOfItsType($field))
+ @push('crud_fields_scripts')
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.js"
+ integrity="sha512-lOrm9FgT1LKOJRUXF3tp6QaMorJftUjowOWiDcG5GFZ/q7ukof19V0HKx/GWzXCdt9zYju3/KhBNdCLzK8b90Q=="
+ crossorigin="anonymous" referrerpolicy="no-referrer"></script>
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.css"
+ integrity="sha512-NXUhxhkDgZYOMjaIgd89zF2w51Mub53Ru3zCNp5LTlEzMbNNAjTjDbpURYGS5Mop2cU4b7re1nOIucsVlrx9fA=="
+ crossorigin="anonymous" referrerpolicy="no-referrer"/>
+ <script>
+ jQuery(document).ready(function ($) {
+ $("#cms_template").on('change', function () {
+ var select = $(this);
+ var ovalue = $(this).find('option[selected]').attr('value');
+ var form = $(this).closest('form');
+ if ($(this).val() != ovalue) {
+ var n = new Noty({
+ modal: true,
+ killer: true,
+ layout: 'center',
+ text: 'Vous êtes sur le point de modifier le template. Le formulaire va être rechargé. Veuillez confirmer votre choix.',
+ buttons: [
+ Noty.button('Confirmer', 'btn btn-success', function () {
+ $.ajax({
+ method: $(form).attr('method'),
+ url: $(form).attr('action'),
+ data: {
+ template: $(select).val(),
+ _token: $(form).find('input[name="_token"]').val(),
+ _method: $(form).find('input[name="_method"]').val(),
+ id: $(form).find('input[name="id"]').val(),
+ },
+ success: function () {
+ window.location.reload();
+ },
+ })
+ }, {id: 'button1', 'data-status': 'ok'}),
+
+ Noty.button('Annuler', 'btn btn-error', function () {
+ $(select).val(ovalue);
+ n.close();
+ })
+ ]
+ });
+ }
+ n.show();
+ });
+ });
+ </script>
+ @endpush
+@endif