How to import form schema

I'm using a separate form schema to try and cut down on repetition and mistakes, but when i do it i have this error Filament\Forms\ComponentContainer::Filament\Forms\Concerns{closure}(): Argument #1 ($component) must be of type Filament\Forms\Components\Component, array given
No description
4 Replies
awcodes
awcodes6mo ago
You’re doubling the array. Schema is returning an array and the $form->schema() is including inside an array.
karim charfaoui
karim charfaouiOP6mo ago
@awcodes and how can i resolve it please
public static function form(Form $form): Form
{
return $form
->schema([
ArticleForm::Schema
])->colums(3)
}
public static function form(Form $form): Form
{
return $form
->schema([
ArticleForm::Schema
])->colums(3)
}
ArticleForm
class ArticleForm
{
public static function schema():array
{
return [
Forms\Components\TextInput::make('name')
->label('Libellé')
->unique(ignoreRecord: true)
->required()
->maxLength(255),
Forms\Components\TextInput::make('code')
->label('Code')
->required()
->unique(ignoreRecord: true)
->maxLength(255),
Forms\Components\Textarea::make('description')
->label('Description')
->columnSpanFull(),
];
}
}
class ArticleForm
{
public static function schema():array
{
return [
Forms\Components\TextInput::make('name')
->label('Libellé')
->unique(ignoreRecord: true)
->required()
->maxLength(255),
Forms\Components\TextInput::make('code')
->label('Code')
->required()
->unique(ignoreRecord: true)
->maxLength(255),
Forms\Components\Textarea::make('description')
->label('Description')
->columnSpanFull(),
];
}
}
Thanks for your help
awcodes
awcodes6mo ago
$form->schema(ArticleForm::schema()) Don’t wrap article form with []
karim charfaoui
karim charfaouiOP6mo ago
yes i see thanks a lot resoleved
Want results from more Discord servers?
Add your server