Forum OpenACS Q&A: Response to Validating form elements with the form builder

Collapse
Posted by Jeff Davis on
Don, the validation is actually done in the template::element::create
routine and the problem is that since it is done there it gets
evaluated in the order that the elements are created.  Hence the
forward reference fails.  I saw two possible solutions, one is to only
validate when you call is_valid (at which point the form is created
and there are no forward references), the other would be to add
validation at the form level for composite checks (which is more or
less what ad_page_contract does).  Either way I think it might break
some older code...

Also, One issue for composite checks is how to attribute the check
back to a particular element for presentation purposes.  I like the
way it's done in ad_page_contract and I think we should only be using
one set of filters in any case so maybe we can figure out a way to do
this that makes ad_page_contract and ad_form be as similiar as
possible in the frontend and share common transform and validation
code.

Tom, I think you have it backwards on why form builder is there -- it
is to make extremely complicated forms managable.  If the form is
small you can do it all the old way and get it right. When you start
talking about something like a CMS system with lots of dynamic content
types you can't manage the complexity without resorting to a form
builder style system to manage the state.  I am a big fan of ad_page_contract and want to preserve it but I know why form builder
is necessary and I think it should be the standard way to handle
user input except in certain special circumstances.