File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -279,10 +279,11 @@ public static function factory(
279279 ): static |FieldClass {
280280 $ field = static ::$ types [$ type ] ?? null ;
281281
282- if (is_string ($ field ) && class_exists ($ field ) === true ) {
283- $ attrs ['siblings ' ] = $ siblings ;
284- unset($ attrs ['type ' ]);
285- return new $ field (...$ attrs );
282+ if (
283+ is_string ($ field ) &&
284+ is_subclass_of ($ field , FieldClass::class) === true
285+ ) {
286+ return $ field ::factory ($ attrs , $ siblings );
286287 }
287288
288289 return new static ($ type , $ attrs , $ siblings );
Original file line number Diff line number Diff line change @@ -106,6 +106,19 @@ public function drawers(): array
106106 return [];
107107 }
108108
109+ /**
110+ * Creates a new field instance from a $props array
111+ * @since 6.0.0
112+ */
113+ public static function factory (
114+ array $ props ,
115+ Fields |null $ siblings = null
116+ ): static {
117+ $ props ['siblings ' ] = $ siblings ;
118+ unset($ props ['type ' ]);
119+ return new static (...$ props );
120+ }
121+
109122 public function id (): string
110123 {
111124 return $ this ->name ();
You can’t perform that action at this time.
0 commit comments