Skip to content
This repository was archived by the owner on Feb 14, 2026. It is now read-only.

Commit f261a1e

Browse files
Add methods to retrieve form field keys and infolist field keys
1 parent ef039c5 commit f261a1e

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/Concerns/Resources/InteractsWithSchemas.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace CodeWithDennis\FilamentTests\Concerns\Resources;
44

5+
use Filament\Forms\Components\Field;
56
use Filament\Infolists\Components\Entry;
67
use Filament\Resources\Pages\EditRecord;
78
use Filament\Resources\Pages\ViewRecord;
@@ -16,6 +17,20 @@ public function getResourceForm(): Schema
1617
));
1718
}
1819

20+
public function getResourceFormFields(): array
21+
{
22+
return $this->getResourceForm()->getFlatFields(true);
23+
}
24+
25+
public function getResourceFormFieldKeys(): array
26+
{
27+
return collect($this->getResourceFormFields())
28+
->map(fn (Field $field) => $field->getName())
29+
->filter()
30+
->values()
31+
->all();
32+
}
33+
1934
public function getResourceInfolist(): Schema
2035
{
2136
return $this->getResource()->infolist(new Schema(
@@ -30,8 +45,12 @@ public function getResourceInfolistFields(): array
3045
->all();
3146
}
3247

33-
public function getResourceFormFields(): array
48+
public function getResourceInfolistFieldKeys(): array
3449
{
35-
return $this->getResourceForm()->getFlatFields(true);
50+
return collect($this->getResourceInfolistFields())
51+
->map(fn (Entry $field) => $field->getName())
52+
->filter()
53+
->values()
54+
->all();
3655
}
3756
}

0 commit comments

Comments
 (0)