]> _ Git - cubist_cms-back.git/commitdiff
wip #4174 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 7 Jan 2021 14:52:46 +0000 (15:52 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 7 Jan 2021 14:52:46 +0000 (15:52 +0100)
src/app/Magic/Fields/FolderTree.php [new file with mode: 0644]
src/app/Magic/Form.php
src/resources/views/form/form.blade.php

diff --git a/src/app/Magic/Fields/FolderTree.php b/src/app/Magic/Fields/FolderTree.php
new file mode 100644 (file)
index 0000000..12a1968
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+
+
+namespace Cubist\Backpack\Magic\Fields;
+
+
+class FolderTree extends SelectFromArray
+{
+    protected $_root = '';
+
+    /**
+     * @param string $root
+     */
+    public function setRoot(string $root): void
+    {
+        $this->_root = $root;
+    }
+
+    /**
+     * @return string
+     */
+    public function getRoot(): string
+    {
+        return $this->_root;
+    }
+
+    /**
+     * @return array
+     */
+    public function getOptions(): array
+    {
+        $options = [];
+
+        $iterator = \Cubist\Util\Files\Files::getRecursiveDirectoryIterator($this->getRoot());
+
+        foreach ($iterator as $item) {
+            /** @var $item \SplFileInfo */
+            if ($item->isFile()) {
+                continue;
+            }
+            $options[$item->getFilename()] = $item->getFilename();
+        }
+        return $options;
+    }
+}
index 7f744b2e8895981d6aca1c540d2e70c0620b9ddb..1588b7dffa9eeee4bbd34485ee0a117b302bf7ea 100644 (file)
@@ -4,6 +4,7 @@
 namespace Cubist\Backpack\Magic;
 
 
+use Cubist\Backpack\CubistBackpackServiceProvider;
 use Illuminate\Support\Facades\Http;
 
 class Form extends SubForm
@@ -26,9 +27,9 @@ class Form extends SubForm
      * @return string
      */
 
-    public function render()
+    public function render(callable $callback = null)
     {
-        return view('form.form', ['form' => $this]);
+        return view(CubistBackpackServiceProvider::NAMESPACE . '::form.form', ['form' => $this])->render($callback);
     }
 
     public function __toString()
@@ -115,4 +116,27 @@ class Form extends SubForm
     {
         return $this->_title;
     }
+
+    public function tabsEnabled()
+    {
+        return false;
+    }
+
+    public function getTabs()
+    {
+        return [];
+    }
+
+    public function fields()
+    {
+        return [];
+    }
+
+    public function getAutoFocusOnFirstField(){
+        return true;
+    }
+
+    public function inlineErrorsEnabled(){
+        return false;
+    }
 }
index ea23659b4e64caabd0431d8abf6dfbe1f2753a38..4fa79ed7dc75b06911d8462ed87f6c9c8b49e46a 100644 (file)
@@ -1,8 +1,9 @@
+@php
+    $crud=$form;
+    $action='create';
+    $fields=$form->fields();
+@endphp
+
 <h2>{{$form->getTitle()}}</h2>
-<div class="card">
-    <form action="{{$form->getAction()}}" method="{{$form->getMethod()}}" enctype="{{$form->getEnctype()}}">
-        @if($form->isCsrf())
-            @csrf
-        @endif
-    </form>
-</div>
+
+@include('crud::form_content')