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...
Neat and clean...thanks you sir.
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:
Thanks for noticing, added the image!
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
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
updateTotalsmethod 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.Hi, thanks. I'll see. Cheers
Is there a way to save a form from an action? I can validate.... but not save!
Why would you need to save the form via action? Expand on the use case, as it depends how you need to do it :)
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
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)