Home
The Toolkit for Online Communities
16673 Community Members, 1 member online, 2541 visitors today
Log In Register
OpenACS Home : Forums : OpenACS Development : Form builder error on hidden fields: Bomb?

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

Icon of envelope Request notifications

Collapse
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?

/Lars

Collapse
Posted by Don Baccus on
None from me!
Collapse
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?
Collapse
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.