FormBuilder::make(route('form.async'))->fields([
Text::make('Name')
])
->async(
callback: AsyncCallback::with(
beforeRequest: 'myBeforeRequest',
responseHandler: 'myResponseHandler',
//Called after standard response processing if responseHandler is not specified
afterResponse: 'myAfterResponse'
)
),
document.addEventListener("moonshine:init", () => {
MoonShine.onCallback('myBeforeRequest', function(form, component) {
console.log('myBeforeRequest', form, component)
})
MoonShine.onCallback('myResponseHandler', function(data, form, events, alpineComponent) {
console.log('myResponseHandler', data, form, events, alpineComponent)
})
// Called after standard response processing if responseHandleris not specified
MoonShine.onCallback('myAfterResponse', function(data, messageType) {
console.log('myAfterResponse', data, messageType)
})
})
Now the fragment has access to events and all the capabilities of AsyncCallback
Refactoring AsyncCallback
Now the fragment has access to events and all the capabilities of AsyncCallback