]> _ Git - cubist_cms-back.git/commitdiff
wip #5734 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 15 Feb 2023 09:41:45 +0000 (10:41 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 15 Feb 2023 09:41:45 +0000 (10:41 +0100)
src/app/Magic/Fields/CheckboxBasic.php [new file with mode: 0644]
src/resources/views/fields/checkboxbasic.blade.php [new file with mode: 0644]

diff --git a/src/app/Magic/Fields/CheckboxBasic.php b/src/app/Magic/Fields/CheckboxBasic.php
new file mode 100644 (file)
index 0000000..f707364
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+namespace Cubist\Backpack\Magic\Fields;
+
+use Cubist\Backpack\CubistBackpackServiceProvider;
+
+class CheckboxBasic extends Checkbox
+{
+    protected $_adminType = 'checkboxbasic';
+    protected $_viewNamespace = CubistBackpackServiceProvider::NAMESPACE . '::fields';
+}
diff --git a/src/resources/views/fields/checkboxbasic.blade.php b/src/resources/views/fields/checkboxbasic.blade.php
new file mode 100644 (file)
index 0000000..df15242
--- /dev/null
@@ -0,0 +1,44 @@
+<!-- checkbox field -->
+
+@include('crud::fields.inc.wrapper_start')
+@include('crud::fields.inc.translatable_icon')
+<div class="checkbox">
+    @php $id='cb_'.rand(100,1000000000); @endphp
+    <input type="hidden" name="{{ $field['name'] }}" value="0">
+    <input id="{{$id}}"  name="{{ $field['name'] }}" type="checkbox" value="1"
+           @if (old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? false)
+               checked="checked"
+    @endif
+
+    @if (isset($field['attributes']))
+        @foreach ($field['attributes'] as $attribute => $value)
+            @if($attribute==='name' || $attribute==='value')
+                @continue
+            @endif
+            {{ $attribute }}="{{ $value }}"
+        @endforeach
+    @endif
+    >
+    <label for="{{$id}}" class="form-check-label font-weight-normal">{!! $field['label'] !!}</label>
+
+    {{-- HINT --}}
+    @if (isset($field['hint']))
+        <p class="help-block">{!! $field['hint'] !!}</p>
+    @endif
+</div>
+@include('crud::fields.inc.wrapper_end')
+
+{{-- ########################################## --}}
+{{-- Extra CSS and JS for this particular field --}}
+{{-- If a field type is shown multiple times on a form, the CSS and JS will only be loaded once --}}
+@if ($crud->fieldTypeNotLoaded($field))
+    @php
+        $crud->markFieldTypeAsLoaded($field);
+    @endphp
+    {{-- FIELD JS - will be loaded in the after_scripts section --}}
+    @push('crud_fields_scripts')
+    @endpush
+
+@endif
+{{-- End of Extra CSS and JS --}}
+{{-- ########################################## --}}