Skip to main content

Form Layouts: Columns, Sections, Tabs, Wizards

Premium
5:09

Text Version of the Lesson

In this lesson, let's explore different options for changing the layout of the form input fields and grouping them in various ways.

Interestingly, similar layout concepts may be reusable in the future, not only for the forms but for other elements on the Filament pages.

I will remind you how our Create Product form looks now in a default Filament layout:

Let's change the way it looks.


Divide the Form into Columns

By default, all forms are divided into two columns.

But what if you want it all vertically in one column?

app/Filament/Resources/ProductResource.php:

return $form
->schema([
// ... all the columns
])
->columns(1);

Here's the result:

Or maybe it's better the other way around, all in one row? We have four fields, so let's put this into a parameter:

app/Filament/Resources/ProductResource.php:

return $form
->schema([
// ... all the columns
])
->columns(4);

This is how the form looks now:

Not only that, you can add a columnSpan() to individual fields of the form.

A typical example is a bigger input like Textarea or RichEditor:

return $form
->schema([
Forms\Components\TextInput::make('name')
->required()
->unique(ignoreRecord: true),
Forms\Components\TextInput::make('price')
->required(),
Forms\Components\RichEditor::make('description')
->columnSpan(2)
->required(),
Forms\Components\Radio::make('status')
->options(self::$statuses),
Forms\Components\Select::make('category_id')
->relationship('category', 'name'),
]);

Then it takes two columns, i.e., the full width:

Another syntax option for a field...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (36 h 00 min)

You also get:

61 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

justgkp avatar

Neat and clean...thanks you sir.

Horváth András avatar

Hello. Excellent quick overview, thank you for that!

One image is missing here: An example of this could be the official Filament demo. Here's the page with the form to create an order:

Povilas Korop avatar

Thanks for noticing, added the image!

Hugo avatar

Hello Everyone, I'm trying to do the example in the demo, I had to change several things and add others but I have a problem with the Total price, I want to know the total of the order to include the repeat. Thanks

Modestas avatar

Hi, this is not covered in this course, but it is available in another course:

https://laraveldaily.com/lesson/filament-crm/customer-quotes-products

In there, you can see updateTotals method and it's usage on how to make this happen real-time. But be aware - it can get confusing, as it's not the easiest thing to do.

Hugo avatar

Hi, thanks. I'll see. Cheers

RicLeP avatar

Is there a way to save a form from an action? I can validate.... but not save!

\Filament\Forms\Components\Actions::make([
\Filament\Forms\Components\Actions\Action::make('Publish')
->action(
function($livewire) {
$livewire->form->validate();
// how to save?
}
)
])
```
Modestas avatar

Why would you need to save the form via action? Expand on the use case, as it depends how you need to do it :)

altersolis avatar

Hi, congrats for explaining so well all the concepts.

What about modifying colors, margins, fonts, etc? I think Filament uses TailwindCSS, but where can we modify such things. Guess it would be on file-components, but where are they?

Thanks in advance

Modestas avatar

Hi, for this - you should look into https://laraveldaily.com/course/filament-visual-customize?mtm_campaign=search-tag-course - as you will have to create a custom theme (even to modify margins on existing elements or change colors)

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.