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.


In reply to Re: CGI::FormBuilder & custom msgs by olus
in thread CGI::FormBuilder & custom msgs by chrism01

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.