From 124e393b7cf654dfd8de1a33ae19237bd3a5918d Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 16 Aug 2022 18:52:04 +0200 Subject: [PATCH] wip #5383 @0.25 --- src/app/Magic/SubForm.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/Magic/SubForm.php b/src/app/Magic/SubForm.php index 4a6560f..2d2c271 100644 --- a/src/app/Magic/SubForm.php +++ b/src/app/Magic/SubForm.php @@ -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); + } } -- 2.39.5