in reply to CGI::FormBuilder & custom msgs

You must validate the return of the database update so that you can check if there were any errors. If there were errors then render the form again with the error messages on the comment element of the fields hash, else show the confirmation page.
You are not checking for errors on do_data_update, just assuming all is well and show the confirmation screen.

Now, to display a message next to the field that may have caused the error, you will need to parse the error message you get, but these messages may not be descriptive enough to let you know which field caused the error.

One thing you must do before sending the data to the database is to validate all the values you get upon form submition and build a data structure that keeps track of the invalid fields. If all values are valid then issue the db update. If not, re-build the form adding comments on the invalid fields and render it. This way it will be less probable to get an error from the db that is related to the fields.

Replies are listed 'Best First'.
Re^2: CGI::FormBuilder & custom msgs
by chrism01 (Friar) on Feb 04, 2008 at 01:23 UTC
    I am checking the DB etc, that's what the $cfg::err_flag var is for. It gets set if any of the subs have a problem. When an error does occur, the prog does go into the relevant block of code, that's what the "log_msg("mytrap");" bit confirms, but as I said, although I set the message option as shown, the form re-renders, but the msg does NOT appear and the debug option (which I also set) does not seem to produce any output.