@@ -138,23 +138,25 @@ class InertiaForm {
138138 this . processing = true ;
139139 this . successful = false ;
140140
141- const then = ( ) => {
141+ const onSuccess = page => {
142142 this . processing = false ;
143143
144144 if ( ! this . hasErrors ( ) ) {
145145 this . onSuccess ( ) ;
146146 } else {
147147 this . onFail ( ) ;
148148 }
149+
150+ if ( options . onSuccess ) {
151+ options . onSuccess ( page )
152+ }
149153 }
150154
151155 if ( requestType === 'delete' ) {
152- return this . __inertia [ requestType ] ( url , options )
153- . then ( then )
156+ return this . __inertia [ requestType ] ( url , { ... options , onSuccess } )
154157 }
155158
156- return this . __inertia [ requestType ] ( url , this . hasFiles ( ) ? objectToFormData ( this . data ( ) ) : this . data ( ) , options )
157- . then ( then )
159+ return this . __inertia [ requestType ] ( url , this . hasFiles ( ) ? objectToFormData ( this . data ( ) ) : this . data ( ) , { ... options , onSuccess } )
158160 }
159161
160162 hasFiles ( ) {
@@ -266,15 +268,15 @@ export default {
266268 . withData ( data )
267269 . withOptions ( options )
268270 . withInertia ( app . config . globalProperties . $inertia )
269- . withPage ( ( ) => app . config . globalProperties . $page ) ,
271+ . withPage ( ( ) => app . config . globalProperties . $page . hasOwnProperty ( 'props' ) ? app . config . globalProperties . $page . props : app . config . globalProperties . $page ) ,
270272 } ) ;
271273 } else {
272274 app . prototype . $inertia . form = ( data = { } , options = { } ) => {
273275 return InertiaForm . create ( )
274276 . withData ( data )
275277 . withOptions ( options )
276278 . withInertia ( app . prototype . $inertia )
277- . withPage ( ( ) => app . prototype . $page ) ;
279+ . withPage ( ( ) => app . prototype . $page . hasOwnProperty ( 'props' ) ? app . prototype . $page . props : app . prototype . $page ) ;
278280 } ;
279281 }
280282 } ,
0 commit comments