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 @@ -107,6 +107,19 @@ public function drawers(): array
107107 return [];
108108 }
109109
110+ /**
111+ * Creates a new field instance from a $props array
112+ * @since 6.0.0
113+ */
114+ public static function factory (
115+ array $ props ,
116+ Fields |null $ siblings = null
117+ ): static {
118+ $ props ['siblings ' ] = $ siblings ;
119+ unset($ props ['type ' ]);
120+ return new static (...$ props );
121+ }
122+
110123 public function id (): string
111124 {
112125 return $ this ->name ();
You can’t perform that action at this time.
0 commit comments