Fix rendering HTML form when API error raised. Closes #2103.