Courses

Filament 3 From Scratch: Practical Course

Column Sort, Search and Validate

You're reading a FREE PREVIEW of a PREMIUM course.
Summary of this lesson:
- Adding field validation
- Implementing sortable columns
- Adding searchable columns
- Understanding global vs individual column search

In this 3-in-1 lesson, let's talk about the most common operations we can do with Filament columns/fields:

  • Validating fields
  • Sort columns in the table
  • Search by table column

I decided to group those into one lesson because they are so easily accomplished in Filament that the lesson will be pretty short, anyway.


Validating Fields in Filament

If you want to add behavior to form fields, you can chain multiple methods to the XxxxxColumn::make() method.

One of the most widely used ones would be ->required() for the validation.

return $form
->schema([
Forms\Components\TextInput::make('name')->required(),
Forms\Components\TextInput::make('price')->required(),
]);

Just by adding this, we have this behavior in the create/edit forms: validation error and asterisk sign near the label.

And there are more Filament methods for validation that you can chain together.

Forms\Components\TextInput::make('name')
->required()
->unique(),

Notice: I start putting those methods on separate lines for better readability.

Some Filament validation methods have extra...

<./article>

The full lesson is only for Premium Members.
Want to access all 24 lessons of this course? (101 min read)

You also get:

  • 76 courses
  • Premium tutorials
  • Access to repositories
  • Private Discord