How to customize data before saving when creating a new option in a modal

When creating a new option via modal, how to customize the data before saving.
Forms\Components\Select::make('tag_id')
->relationship('tag', 'name')
->createOptionForm([
Forms\Components\TextInput::make('name')
->required()
->reactive()
->afterStateUpdated(fn (Set $set, ?string $state) => $set('slug', Str::slug($state)))
->maxLength(255),
Forms\Components\TextInput::make('slug')
->required()
->maxLength(255),
])
->required(),
Forms\Components\Select::make('tag_id')
->relationship('tag', 'name')
->createOptionForm([
Forms\Components\TextInput::make('name')
->required()
->reactive()
->afterStateUpdated(fn (Set $set, ?string $state) => $set('slug', Str::slug($state)))
->maxLength(255),
Forms\Components\TextInput::make('slug')
->required()
->maxLength(255),
])
->required(),
Need to add user_id to the tag, and there is no TagResource so no way to customize in CreateTag page, is there any other way to do it?
2 Replies
LeandroFerreira
LeandroFerreira15mo ago
->createOptionUsing(function (array $data) {
//
})
->createOptionUsing(function (array $data) {
//
})
?
Iranzi Dev
Iranzi Dev14mo ago
How can i handle that cause I don't mean this function clear I want to save image in backup and storage folder at the same time
Want results from more Discord servers?
Add your server