F
Filament7mo ago
Taz416

Relation Manager Lifecycle Hooks

Is there a way to use a beforeUpdate hook before the relation manager form is saved? I don't seem to be able to get anything to work. I have a Checkbox list that I want to validate what gets saved to the database.
2 Replies
Taz416
Taz416OP7mo ago
I can use the beforeStateDehydrated on the field I guess and do custom validation in the model so I guess it is not a deal breaker. Though is there any way to add a beforeSave somewhere since the relation manager does not have a edit-record page to add it. ??
johnnie_littleshoes
I believe Action lifecycle hooks is what you (and I) were looking for:
CreateAction::make()
->beforeFormFilled(function () {
// Runs before the form fields are populated with their default values.
})
->afterFormFilled(function () {
// Runs after the form fields are populated with their default values.
})
->beforeFormValidated(function () {
// Runs before the form fields are validated when the form is submitted.
})
->afterFormValidated(function () {
// Runs after the form fields are validated when the form is submitted.
})
->before(function () {
// Runs before the form fields are saved to the database.
})
->after(function () {
// Runs after the form fields are saved to the database.
})
CreateAction::make()
->beforeFormFilled(function () {
// Runs before the form fields are populated with their default values.
})
->afterFormFilled(function () {
// Runs after the form fields are populated with their default values.
})
->beforeFormValidated(function () {
// Runs before the form fields are validated when the form is submitted.
})
->afterFormValidated(function () {
// Runs after the form fields are validated when the form is submitted.
})
->before(function () {
// Runs before the form fields are saved to the database.
})
->after(function () {
// Runs after the form fields are saved to the database.
})
Want results from more Discord servers?
Add your server