]> _ Git - cubist_cms-back.git/commitdiff
wip #7063 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 4 Sep 2024 17:03:19 +0000 (19:03 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 4 Sep 2024 17:03:19 +0000 (19:03 +0200)
src/resources/views/fields/external_path.blade.php

index 76dbcc625d79190544bd4a3f5d3100d638f6f59e..1104e48b62618a5ba8179d4db0f8c7c4b5e9aa42 100644 (file)
@@ -1,5 +1,15 @@
 <!-- range of values -->
 <?php
+
+$serversClass = $field['servers_model'];
+$servers = $serversClass::getAllServers();
+
+if ($field['default'] === '__FIRST__') {
+    foreach ($servers as $i => $server) {
+        $field['default'] = ['server' => $i, 'path' => ''];
+    }
+}
+
 $empty = ['server' => '', 'path' => ''];
 $value = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? $empty;
 if ($value == '') {
@@ -20,8 +30,6 @@ if (!isset($value['path'])) {
     $value['path'] = '';
 }
 
-$serversClass = $field['servers_model'];
-$servers = $serversClass::getAllServers();
 
 ?>
 @include('crud::fields.inc.wrapper_start')
@@ -107,14 +115,14 @@ $servers = $serversClass::getAllServers();
             function liveslugify(text) {
                 return text
                     .toString()// Cast to string (optional)
-                    .replace(/\/+/g,'fwdslash')
+                    .replace(/\/+/g, 'fwdslash')
                     .normalize('NFKD')            // The normalize() using NFKD method returns the Unicode Normalization Form of a given string.
                     .replace(/\s+/g, '-')         // Replace spaces with -
                     .replace(/[^\w\-]+/g, '')     // Remove all non-word chars
-//                    .replace(/\_/g, '-')           // Replace _ with -
+                    //                    .replace(/\_/g, '-')           // Replace _ with -
                     .replace(/\-\-+/g, '-')       // Replace multiple - with single -
                     //.replace(/\-$/g, '')         // Remove trailing -
-                    .replace(/fwdslash/g,'/');
+                    .replace(/fwdslash/g, '/');
             }
 
             $(function () {