Factored out saveModal to a function so that the enter key submit code doesn't trigger it twice