Hi Roberto,
you get the action the user clicked with:
set action_id [form get_action contract]
do this OUTSIDE ad_form (at least that's what I do - up the top where you gather all your useful info like user_id, workflow_id etc.).
in any case, you need the action id before you check permissions. if you are using workflow, it would look like this:
if { ![workflow::case::action::available_p -case_id $case_id -action_id $action_id] } {
handle the security violation
}
then i do this:
set actions [list]
if { [empty_string_p $action_id] } {
if the action_id is an empty string, then we want to
display the form, so build the list of actions.
}
then I do the ad_form
in the on_submit block I act on the action as appropriate. if you are using workflow, it will look something like this:
if { ![empty_string_p $action_id] } {
foreach field [workflow::action::get_element -action_id $action_id -element edit_fields] {
set row($field) [element get_value contract $field]
}
}
followed by a db update or whatever your action requires
and at the end of the on_submit block I do a ad_returnredirect/ad_script_abort