]> _ Git - cubist_cms-back.git/commitdiff
wip #3939 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 8 Oct 2020 17:19:06 +0000 (19:19 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 8 Oct 2020 17:19:06 +0000 (19:19 +0200)
src/app/Magic/Fields/Code.php [new file with mode: 0644]
src/resources/views/fields/code.blade.php [new file with mode: 0644]

diff --git a/src/app/Magic/Fields/Code.php b/src/app/Magic/Fields/Code.php
new file mode 100644 (file)
index 0000000..0a64ef3
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+
+
+namespace Cubist\Backpack\app\Magic\Fields;
+
+
+use Cubist\Backpack\CubistBackpackServiceProvider;
+
+class Code extends Textarea
+{
+    protected $_adminType = 'code';
+    protected $_databaseType = 'text';
+    protected $_translatable = true;
+    protected $_language = 'text';
+    protected $_viewNamespace = CubistBackpackServiceProvider::NAMESPACE . '::fields';
+
+    public function getDefaultAttributes()
+    {
+        return array_merge(parent::getDefaultAttributes(), ['language' => $this->_language]);
+    }
+}
diff --git a/src/resources/views/fields/code.blade.php b/src/resources/views/fields/code.blade.php
new file mode 100644 (file)
index 0000000..71a003a
--- /dev/null
@@ -0,0 +1,25 @@
+<!-- textarea -->
+@include('crud::fields.inc.wrapper_start')
+<label>{!! $field['label'] !!}</label>
+@include('crud::fields.inc.translatable_icon')
+<textarea
+    class="code"
+    name="{{ $field['name'] }}"
+        @include('crud::fields.inc.attributes')
+
+       >{{ old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? '' }}</textarea>
+
+{{-- HINT --}}
+@if (isset($field['hint']))
+    <p class="help-block">{!! $field['hint'] !!}</p>
+@endif
+@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->checkIfFieldIsFirstOfItsType($field))
+textarea.code{
+        font-family: Courier, monospace;
+}
+@endif