F
Filamentβ€’11mo 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
AzorkyOPβ€’11mo ago
Yes I'm using split, but I can't figure out way to have a fixed with or something like that
Matthew
Matthewβ€’11mo 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
AzorkyOPβ€’11mo 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
Matthewβ€’11mo 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
AzorkyOPβ€’11mo ago
Good idea!
Azorky
AzorkyOPβ€’11mo 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
Matthewβ€’11mo ago
You can change values with Get Set They are called dependable states or something like that Dependant fields
Azorky
AzorkyOPβ€’11mo ago
Found it! πŸ™‚
Solution
Azorky
Azorkyβ€’11mo ago
->columnSpan(fn (Get $get) => $get('project_id') ? 3 : 4)
->columnSpan(fn (Get $get) => $get('project_id') ? 3 : 4)
Matthew
Matthewβ€’11mo ago
nice
Azorky
AzorkyOPβ€’11mo ago
Whilst you can't pass a closure to columns, you can with columnSpan Thanks for helping out!
Want results from more Discord servers?
Add your server