I frequently get burnt on formbuilder forms that don't work, because there's an error in a hidden field, typically because it's not -optional, but doesn't have any contents.
It's really annoying, because the only way you find out is that you wonder, then check a couple things, then realize that it never validates.
So I added a proc 'form get_errors (id)' which will get you the errors for the form, so you can spit them out like this:
error [form get_error my_form]
But really, shouldn't we simply bomb when there's a validation error on a hidden field? Is this ever a useful situation?
I can see that the code already has a check for this, in element-procs.tcl:
# no value was submitted for a required element
set formerror($element_id) "$label is required"
set formerror($element_id:required) "$label is required"
if { [lsearch -exact {hidden submit} $element(widget)] > -1 } {
ns_log Notice "No value for element $label"
}
I'd suggest we change the ns_log Notice to a straight-up error, that says "Hidden required field has no value".
Any complaints?
/Lars