jqh 5 years ago
parent
commit
05d1f8fc98
2 changed files with 8 additions and 10 deletions
  1. 4 4
      src/Form/Builder.php
  2. 4 6
      src/Form/Field/UploadField.php

+ 4 - 4
src/Form/Builder.php

@@ -819,11 +819,11 @@ class Builder
         $tabObj = $this->form->getTab();
 
         if (! $tabObj->isEmpty()) {
-            $this->setupTabScript();
+            $this->addTabScript();
         }
 
         if ($this->form->allowAjaxSubmit() && empty($this->stepBuilder)) {
-            $this->setupSubmitScript();
+            $this->addSubmitScript();
         }
 
         $open = $this->open(['class' => 'form-horizontal']);
@@ -864,7 +864,7 @@ EOF;
     /**
      * @return void
      */
-    protected function setupSubmitScript()
+    protected function addSubmitScript()
     {
         Admin::script(
             <<<JS
@@ -878,7 +878,7 @@ JS
     /**
      * @return void
      */
-    protected function setupTabScript()
+    protected function addTabScript()
     {
         $elementId = $this->getElementId();
 

+ 4 - 6
src/Form/Field/UploadField.php

@@ -156,9 +156,11 @@ trait UploadField
     /**
      * Indicates if the underlying field is retainable.
      *
+     * @param bool $retainable
+     *
      * @return $this
      */
-    public function retainable($retainable = true)
+    public function retainable(bool $retainable = true)
     {
         $this->retainable = $retainable;
 
@@ -364,10 +366,6 @@ trait UploadField
      */
     public function destroy()
     {
-        if ($this->retainable) {
-            return;
-        }
-
         $this->deleteFile($this->original);
     }
 
@@ -395,7 +393,7 @@ trait UploadField
      */
     public function deleteFile($paths)
     {
-        if (! $paths) {
+        if (! $paths || $this->retainable) {
             return;
         }