set on_submit { code here }
append on_submit { more code }
ad_form -extend -on_submit $on_submit
Just build up the code block dynamically.