FilamentF
Filament15mo ago
Asmit

Custom Field Send Multiple Data

I have to create a custom field and I have to send extra form data while submit the form with extra customization. like
Here I make custom field by extending Rich Editor
CustomBio::make('bio')
  ->columnSpanFull(),

This is my custom field class
<?php

namespace PackiMaster\Bio\Forms\Components;

use Filament\Forms\Components\RichEditor;
use Filament\Forms\Set;

class CustomBio extends RichEditor
{
    protected string $view = 'bio::forms.components.bio-editor';

    protected array|\Closure $mentionsItems = [];

    public function setUp(): void
    {
        parent::setUp();

        // Adding a hook to modify the form data on submission
        $this->afterStateHydrated(function ($component, $state, Set $set) {
            // Original state remains untouched
            $set($this->getStatePath(), $state);

            // Add mentions as separate data
            $set('bio_with_style', 'SOME_EXTRA_CUSTOMIZATION');
        });

    }
 
}


How to send extra data
bio_with_style
on submit the form ?
Was this page helpful?