Forum OpenACS Development: Form builder error on hidden fields: Bomb?

Request notifications

Posted by Lars Pind on
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?


Posted by Don Baccus on
None from me!
Posted by Jeff Davis on
Lars committed some of this on the HEAD.
Should we make this change in 4.6 and pull the new
proc in as well?
Posted by Don Baccus on
I'd suggest just putting in the bomb and not the proc, since normally one wants to use the normal form builder error output style anyway.  The "hidden" widget should be the only one that hides itself and its errors so bombing on errors in a "hidden" widget should be sufficient ...

IMO that is.