Forum OpenACS Q&A: Re: scope of variables when using ad_form

Collapse
Posted by Dave Bauer on
You can do this:
1) do the validation in the on_submit block
2) set form error on the element in question if it doesn't validate
3) return the template early and terminate the submit processing.

ie:

-on_submit {
if {![expensive_validation_proc]} {
element set_error $form_id $element_id "Error Message"
ad_return_template
ad_script_abort; # make sure you abort or the processing will continue
}

Collapse
Posted by Brian Fenton on
Thanks Dave,

that sounds good. By doing it that way, you don't "lose" any of the regular -validate functionality do you? I can't see how (as all -validate seems to do is set the error) but just making doubly sure (or as we say in Ireland "to be sure to be sure").

thanks as always
Brian