@@ -217,22 +217,22 @@ public function mapFilterType(BaseFilter $filter): string
217
217
};
218
218
}
219
219
220
- public function mapFormComponent (Component $ component , Resource $ resource ): ?array
220
+ public function mapFormComponent (Component $ component , ? Resource $ resource = null ): ?array
221
221
{
222
222
$ baseInfo = [
223
223
'name ' => $ component ->getName (),
224
224
'type ' => $ this ->mapComponentType ($ component ),
225
225
'label ' => $ component ->getLabel (),
226
226
'required ' => method_exists ($ component , 'isRequired ' ) ? $ component ->isRequired () : null ,
227
- 'disabled ' => method_exists ($ component , 'isDisabled ' ) ? $ component ->isDisabled () : null ,
227
+ // 'disabled' => method_exists($component, 'isDisabled') ? $component->isDisabled() : null, // Needs container to be instantiated
228
228
// 'nullable' => method_exists($component, 'isNullable') ? $component->isNullable() : null, // Needs checking validation rules
229
229
];
230
230
231
231
if ($ component instanceof TextInput) {
232
232
$ baseInfo ['maxLength ' ] = $ component ->getMaxLength ();
233
233
}
234
234
235
- if ($ component instanceof Select && $ component ->getRelationshipName ()) {
235
+ if ($ resource && $ component instanceof Select && $ component ->getRelationshipName ()) {
236
236
$ modelClass = $ resource ::getModel ();
237
237
$ modelInstance = app ($ modelClass );
238
238
$ relationshipDefinition = $ modelInstance ->{$ component ->getRelationshipName ()}();
@@ -293,6 +293,21 @@ public function mapTableFilter(BaseFilter $filter): array
293
293
$ baseInfo ['optionsSource ' ] = $ options ;
294
294
}
295
295
}
296
+
297
+ if ($ filter ->hasFormSchema ()) {
298
+ /** @var Component $component */
299
+ $ fields = collect ($ filter ->getFormSchema ())
300
+ ->reject (fn (Component $ component ) => $ component instanceof Grid || $ component instanceof Fieldset)
301
+ ->map (fn (Component $ component ) => $ this ->mapFormComponent ($ component ))
302
+ ->filter ()
303
+ ->values ()
304
+ ->all ();
305
+
306
+ if ($ fields ) {
307
+ $ baseInfo ['fields ' ] = $ fields ;
308
+ }
309
+ }
310
+
296
311
// Add more specific filter type mappings here if needed
297
312
298
313
return $ baseInfo ;
0 commit comments