Advanced

Custom Field Types

Build your own field types to extend FilaForms.

FilaForms ships with 25+ field types, but you can create custom ones. Each field type defines its form component, table column, infolist entry, validation rules, and submission processing.

Creating a Field Type

Extend BaseFieldType and implement the configure() method using the FieldSchema builder.

app/Filament/FieldTypes/StarRatingFieldType.php
use FilaForms\Core\FieldTypes\BaseFieldType;
use FilaForms\Core\FieldTypes\FieldSchema;

class StarRatingFieldType extends BaseFieldType
{
    public function configure(): FieldSchema
    {
        return FieldSchema::numeric()
            ->key('star-rating')
            ->label('Star Rating')
            ->icon('heroicon-o-star')
            ->formComponent(StarRatingComponent::class)
            ->availableValidationRules([
                ValidationRule::REQUIRED,
                ValidationRule::MIN,
                ValidationRule::MAX,
            ])
            ->searchable()
            ->sortable();
    }
}

FieldSchema Builder Methods

Static Constructors

Each constructor sets the underlying FieldDataType for storage and casting.

MethodData Type
FieldSchema::text()Text / string
FieldSchema::numeric()Integer
FieldSchema::float()Float
FieldSchema::boolean()Boolean
FieldSchema::date()Date
FieldSchema::dateTime()DateTime
FieldSchema::singleChoice()Single choice (string)
FieldSchema::multiChoice()Multiple choice (array)

Configuration Methods

MethodDescription
key(string)Unique identifier for the field type
label(string)Display name shown in the field type picker
icon(string)Heroicon name for the field type picker
formComponent(string)Filament form component class
tableColumn(Closure)Returns a Filament table column
tableFilter(Closure)Returns a Filament table filter
infolistEntry(Closure)Returns a Filament infolist entry
priority(int)Sort order in field type picker (default 500)
availableValidationRules(array)Rules users can add via the form builder
defaultValidationRules(array)Rules applied automatically to every instance
searchable(bool)Allow searching submissions by this field
sortable(bool)Allow sorting submissions by this field
filterable(bool)Allow filtering submissions by this field
encryptable(bool)Support field-level encryption
withSettings(string $dataClass, Closure $schema)Custom settings form for the field type
exclusiveGroup(string)Only one field of this group allowed per form
scripts(array)External JS scripts to load with the field
postSubmissionComponent(string)Livewire component shown after submit

Processing Submission Values

Override processSubmissionValue() to transform data before storage.

app/Filament/FieldTypes/StarRatingFieldType.php
public function processSubmissionValue(mixed $value, Form $form, string $fieldCode): mixed
{
    // Transform the value before it's stored
    return (int) round($value);
}

Custom Settings

Add field-type-specific configuration using withSettings(). The first argument is a Spatie Laravel Data class. The second is a closure returning the Filament form schema.

app/Filament/FieldTypes/StarRatingFieldType.php
FieldSchema::numeric()
    ->key('star-rating')
    ->withSettings(
        StarRatingSettings::class,
        fn () => [
            TextInput::make('max_stars')
                ->numeric()
                ->default(5),
        ]
    );

The settings data class extends Spatie\LaravelData\Data:

app/Filament/FieldTypes/StarRatingSettings.php
use Spatie\LaravelData\Data;

class StarRatingSettings extends Data
{
    public function __construct(
        public int $max_stars = 5,
    ) {}
}

Registering Field Types

Register custom field types in your panel provider.

app/Providers/Filament/AdminPanelProvider.php
FilaFormsPlugin::make()
    ->registerFieldTypes([
        StarRatingFieldType::class,
    ])

Restricting Field Types

Whitelist specific field types to limit what users can add to forms.

app/Providers/Filament/AdminPanelProvider.php
FilaFormsPlugin::make()
    ->onlyFieldTypes(['text', 'email', 'select', 'star-rating'])
You can also use the field_types.enabled and field_types.disabled arrays in the FilaForms config file for static restriction without modifying the panel provider.
Copyright © 2026