]> _ Git - cubist_cms-back.git/commitdiff
wip #5383 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 16 Aug 2022 16:52:04 +0000 (18:52 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 16 Aug 2022 16:52:04 +0000 (18:52 +0200)
src/app/Magic/SubForm.php

index 4a6560ff38e6bfc7ceeb13f82009a53727f3d961..2d2c271dfe428588e5b19c55da675c9644efac30 100644 (file)
@@ -6,7 +6,9 @@ namespace Cubist\Backpack\Magic;
 
 class SubForm
 {
-    use BunchOfFields;
+    use BunchOfFields{
+        addField as bofAddField;
+    }
 
     public function __construct()
     {
@@ -16,4 +18,13 @@ class SubForm
     public function init(){
 
     }
+
+    public function addField($name, $type = 'Text', $label = '', $attributes = [])
+    {
+        $reserved = ['type','name'];
+        if (in_array($name, $reserved)) {
+            throw new \Exception('The field name `' . $name . '` is a reserved name and can not be used in a subform.');
+        }
+        return $this->bofAddField($name,$type,$label,$attributes);
+    }
 }