Parcourir la source

支持自定义ID

jqh il y a 4 ans
Parent
commit
7d2b464d74
1 fichiers modifiés avec 3 ajouts et 2 suppressions
  1. 3 2
      src/Form/Tab.php

+ 3 - 2
src/Form/Tab.php

@@ -52,17 +52,18 @@ class Tab
      * @param string   $title
      * @param \Closure $content
      * @param bool     $active
+     * @param string   $id
      *
      * @return $this
      */
-    public function append($title, \Closure $content, $active = false)
+    public function append($title, \Closure $content, bool $active = false, ?string $id = null)
     {
         call_user_func($content, $this->form);
 
         $fields = $this->collectFields();
         $layout = $this->collectColumnLayout();
 
-        $id = 'tab-form-'.($this->tabs->count() + 1).'-'.mt_rand(0, 9999);
+        $id = $id ?: ('tab-form-'.($this->tabs->count() + 1).'-'.mt_rand(0, 9999));
 
         $this->tabs->push(compact('id', 'title', 'fields', 'active', 'layout'));