On my site, data entry forms kind of look like dialogs. Because of the presentation, I prefer to surface data entry errors outside the "dialog" area. For an example of said behavior, please goto my contact form and click "Send" with out entering any data.
Is it possible to do this with FormHandler? I'm new to this excellent tool, and it looks like the error is always output in proximity to the data entry field.
1. Use a different mask. By default, FormHandler uses a single row mask, repeated for every field. You can easaly change this into a complete "table" (template-like). If you use a complete table as mask, you can put the %error% placeholder outside of your table. Then, at last, you can change the error messages with setErrorMessage (e.g. that messages like "this field is incorrect" can be changed into "the name is incorrect").
2. Use the catch error function in formhandler. Problem is that some errors (database check errors, e.g. unique field checks) are not catched with this function (known bug). Also known bug is that the function getTitle not works when flush() is called.
but only because I couldn't do it any other way (well, maybe I could have but I am just a LAZY SOD...!).
Personally, it seems to me to make more sense to place the error message in close proximity to the field containing the error. I think this is especially true for longer forms with many fields.
IMHO. :-)
Here is what I have done:
<?php
$form->setErrorMessage( "email", "<br /><font color=\"red\"><strong>You must enter a valid Email address!</strong></font>");
?>
by adding the <br />, the error msg appears immediately under the field with the error.
If you just want to place the error message under the field, you could just use a css class. By default, all error messages get a css class named "error" (See 'FH_ERROR_MASK' in the config file). If you use a css class like this below, the error messages should appear below the field.