F
Filament4mo ago
Hagi

Grid and Columns in v4

I am a little confused with the new grid & columns format in v4, because when I use grid columns the results are not the same. Can you help me? Code : public static function configure(Schema $schema): Schema { return $schema ->components([ Grid::make() ->schema([ Section::make() ->schema([ TextInput::make('name') ->label('Name') ->required() ->columnSpanFull() ->inlineLabel() ->reactive(), TextInput::make('email') ->label('Email') ->columnSpanFull() ->required() ->inlineLabel(), TextInput::make('password') ->password() ->inlineLabel() ->columnSpanFull() ->dehydrateStateUsing(fn ($state) => Hash::make($state)) ->dehydrated(fn ($state) => filled($state)) ->required(fn (string $context): bool => $context === 'create'), DateTimePicker::make('email_verified_at') ->label('Email Verifikasi') ->columnSpanFull() ->inlineLabel(),
]) ->columnSpan(3) ]) ->columns(3), ]);
}
No description
Solution:
If that's all you have your Grid seems unnecessary. You can put ->columns(3) on the Form itself.
Jump to solution
9 Replies
toeknee
toeknee4mo ago
In the schema you haven't set the columns to used.. You set it on Grid, but not the columnSpan it should use. You will want to make the Grid columnSpanFull() to be the full width. At the moment it's 2 columns and that first grid uses 1 half. Then you have a Section which uses all columns again, and full width inputs to deliver exactly what you hvae asked for If you explain what you are trying to achieve? And also. you could format the code type too when post code examples. i.e. 3 of: ` with a php so like : ``php
Hagi
HagiOP4mo ago
I want it to be like the image that uses Filament V3, so the Columns fit and match, and when I apply it to V4 the layout doesn't match, I don't know if it's a bug or what. And this code
No description
No description
Hagi
HagiOP4mo ago
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Grid::make()
->schema([
Section::make()
->schema([
TextInput::make('name')
->label('Name')
->required()
->columnSpanFull()
->inlineLabel()
->reactive(),
TextInput::make('email')
->label('Email')
->columnSpanFull()
->required()
->inlineLabel(),
])
->columnSpan(2),
Section::make()
->schema([
TextInput::make('password')
->password()
->inlineLabel()
->columnSpanFull()
->dehydrateStateUsing(fn ($state) => Hash::make($state))
->dehydrated(fn ($state) => filled($state))
->required(fn (string $context): bool => $context === 'create'),
DateTimePicker::make('email_verified_at')
->label('Email Verifikasi')
->columnSpanFull()
->inlineLabel(),
])
->columnSpan(1)
])
->columns(3),
]);
}
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Grid::make()
->schema([
Section::make()
->schema([
TextInput::make('name')
->label('Name')
->required()
->columnSpanFull()
->inlineLabel()
->reactive(),
TextInput::make('email')
->label('Email')
->columnSpanFull()
->required()
->inlineLabel(),
])
->columnSpan(2),
Section::make()
->schema([
TextInput::make('password')
->password()
->inlineLabel()
->columnSpanFull()
->dehydrateStateUsing(fn ($state) => Hash::make($state))
->dehydrated(fn ($state) => filled($state))
->required(fn (string $context): bool => $context === 'create'),
DateTimePicker::make('email_verified_at')
->label('Email Verifikasi')
->columnSpanFull()
->inlineLabel(),
])
->columnSpan(1)
])
->columns(3),
]);
}
Dennis Koch
Dennis Koch4mo ago
There's a columnSpanFull() missing on the Grid. Because by default forms have 2 columns
toeknee
toeknee4mo ago
Exactly
Solution
Dennis Koch
Dennis Koch4mo ago
If that's all you have your Grid seems unnecessary. You can put ->columns(3) on the Form itself.
Dennis Koch
Dennis Koch4mo ago
Or put ->columns(1) on the form and use your Grid
Hagi
HagiOP4mo ago
okay this works well and simpler i think than v3, no wonder i tried using v3 the result was not the same. thanks for your feedback
Dan Harrin
Dan Harrin4mo ago
read the upgrade guide, the default behaviour for column spans on some components has changed so its more consistent in v4

Did you find this page helpful?