Allow overriding onSubmit event in dialogs.

Fixes #2327 , #2326 

@ussuri  PTAL thanks.