is there a way to mutate data on createOptionForm in Select input.
i want to attach the creator_id before saving the form instead of having the a readonly field.
Forms\Components\Select::make('payment_method_id')
->label('Payment Method')
->relationship(name: 'paymentMethod', titleAttribute: 'name')
->required()
->createOptionForm([
Forms\Components\TextInput::make('name')->required(),
Forms\Components\Textarea::make('description')->helperText('more about channel, eg bank acc nu')->required(),
Forms\Components\TextInput::make('creator_id')->default(Auth::id())->readOnly(),
]),
4 Replies
Do you need to mutate the data before save or before show?
before save.
I couldn’t find any other way to do it via filament. But, you could probably use model observers to perform a “before save” action.
you can create an observer using
php artisan make:observer --model=PaymentMethod
and then only use the saving
event
Then, in App\Providers\EventServiceProvider
thanks. i thought filament had a way but observer will work just fine. Thankyou.