How to Create an SEO Component

Hello, I need to create a reusable component where inside it will have a GROUP of 3 TextInputs. How do I go about creating such a component? Since these InputText will have an action that will copy the content of other TextInputs in this same form. It will be an SEO component that will have a textInput of title that will copy the content of another textInput of title, will have another of Description and another of SLUG. I hope I managed to explain. Thanks
2 Replies
Patrick Boivin
One option to handle reusable fields is to have a simple class that returns a Group, something like this:
use Filament\Forms\Components\Group;

class MyReusableFields
{
public static function make(): Group
{
return Group::make([
// your fields
]);
}
}
use Filament\Forms\Components\Group;

class MyReusableFields
{
public static function make(): Group
{
return Group::make([
// your fields
]);
}
}
Then in your forms, you can use it like a regular field:
public static function form(Form $form): Form
{
return $form->schema([
MyReusableFields::make(),

// ...
]);
}
public static function form(Form $form): Form
{
return $form->schema([
MyReusableFields::make(),

// ...
]);
}
joao nivaldo
joao nivaldoOP2y ago
Show. Thanks
Want results from more Discord servers?
Add your server