jqh 4 vuotta sitten
vanhempi
commit
f1ac7216cf
2 muutettua tiedostoa jossa 7 lisäystä ja 2 poistoa
  1. 1 1
      src/Form.php
  2. 6 1
      src/Traits/HasFormResponse.php

+ 1 - 1
src/Form.php

@@ -952,7 +952,7 @@ class Form implements Renderable
             return rtrim($resourcesPath, '/')."/{$key}";
         }
 
-        return $this->request->get(Builder::PREVIOUS_URL_KEY) ?: ($this->getCurrentUrl() ?: $resourcesPath);
+        return $this->request->get(Builder::PREVIOUS_URL_KEY) ?: $this->getCurrentUrl($resourcesPath);
     }
 
     /**

+ 6 - 1
src/Traits/HasFormResponse.php

@@ -51,11 +51,12 @@ trait HasFormResponse
     /**
      * 获取当前URL.
      *
+     * @param string|null  $default
      * @param Request|null $request
      *
      * @return string
      */
-    protected function getCurrentUrl(Request $request = null)
+    protected function getCurrentUrl($default = null, Request $request = null)
     {
         if ($this->currentUrl) {
             return admin_url($this->currentUrl);
@@ -68,6 +69,10 @@ trait HasFormResponse
             return admin_url($current);
         }
 
+        if ($default !== null) {
+            return $default;
+        }
+
         $query = $request->query();
 
         if (method_exists($this, 'sanitize')) {