F
Filament13mo ago
Azorky

Split item width

Is it possible to use split whilst making one of the items a fixed width for example? Maybe with breakpoints as well. Because currently I have grow set to false and it looks a bit silly:
No description
Solution:
->columnSpan(fn (Get $get) => $get('project_id') ? 3 : 4)
->columnSpan(fn (Get $get) => $get('project_id') ? 3 : 4)
Jump to solution
13 Replies
Azorky
AzorkyOP13mo ago
Yes I'm using split, but I can't figure out way to have a fixed with or something like that
Matthew
Matthew13mo ago
Try something like this:
public static function form(Form $form): Form
{
return $form
->schema(function () {
$schema = [
'left' => Section::make([
'name' => TextInput::make('name')
->required(),
'email' => TextInput::make('email')
->required()
->unique(ignoreRecord: true),
// ...
])->columnSpan(8),
'right' => Section::make([
'created_at' => Placeholder::make('created_at')
])->columnSpan(4),
];
})
->columns(12);
}
public static function form(Form $form): Form
{
return $form
->schema(function () {
$schema = [
'left' => Section::make([
'name' => TextInput::make('name')
->required(),
'email' => TextInput::make('email')
->required()
->unique(ignoreRecord: true),
// ...
])->columnSpan(8),
'right' => Section::make([
'created_at' => Placeholder::make('created_at')
])->columnSpan(4),
];
})
->columns(12);
}
Azorky
AzorkyOP13mo ago
The code you sent would be the ideal solution, but the problem is that ->columns is only accepting array|int|string|null, but not a closure. And I need a closure because the planning section is optional and not always visible. In case it's invisible, the "Algemeen" section should fill the screen.
No description
No description
Matthew
Matthew13mo ago
ja ok, but you can have the function inside the form function, then define a vairable $columns, and have the as input to ->columns()
Azorky
AzorkyOP13mo ago
Good idea!
Azorky
AzorkyOP13mo ago
Hmm it doesn't work. It's because it all depends on whether this field has a value or not, and apparently I can't change it's value, probably because form is a static function I'm guessing
No description
Matthew
Matthew13mo ago
You can change values with Get Set They are called dependable states or something like that Dependant fields
Azorky
AzorkyOP13mo ago
Found it! 🙂
Solution
Azorky
Azorky13mo ago
->columnSpan(fn (Get $get) => $get('project_id') ? 3 : 4)
->columnSpan(fn (Get $get) => $get('project_id') ? 3 : 4)
Matthew
Matthew13mo ago
nice
Azorky
AzorkyOP13mo ago
Whilst you can't pass a closure to columns, you can with columnSpan Thanks for helping out!

Did you find this page helpful?