Merge pull request #17166 from valpuia/patch-3

Update 03-creating-records.md
This commit is contained in:
Dan Harrin
2025-08-02 06:23:50 -06:00
committed by GitHub
+7 -8
View File
@@ -322,18 +322,17 @@ public function hasSkippableSteps(): bool
}
```
### Sharing fields between the resource form and wizards
### Sharing fields between the form schema and wizards
If you'd like to reduce the amount of repetition between the resource form and wizard steps, it's a good idea to extract public static resource functions for your fields, where you can easily retrieve an instance of a field from the resource or the wizard:
If you'd like to reduce the amount of repetition between the resource form and wizard steps, it's a good idea to extract public static form functions for your fields, where you can easily retrieve an instance of a field from the form schema or the wizard:
```php
use Filament\Forms;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
class CategoryResource extends Resource
class CategoryForm
{
public static function form(Schema $schema): Schema
public static function configure(Schema $schema): Schema
{
return $schema
->components([
@@ -362,7 +361,7 @@ class CategoryResource extends Resource
```
```php
use App\Filament\Resources\Categories\CategoryResource;
use App\Filament\Resources\Categories\Schemas\CategoryForm;
use Filament\Resources\Pages\CreateRecord;
class CreateCategory extends CreateRecord
@@ -377,8 +376,8 @@ class CreateCategory extends CreateRecord
Step::make('Name')
->description('Give the category a clear and unique name')
->schema([
CategoryResource::getNameFormField(),
CategoryResource::getSlugFormField(),
CategoryForm::getNameFormField(),
CategoryForm::getSlugFormField(),
]),
// ...
];