Forum OpenACS Q&A: Re: Re: Re: Re: ad_form: What's my mode?

Collapse
Posted by Sean Redmond on

-edit_request comes to late, or the scope is wrong. Also, I'm not testing for new vs. edit but for display vs.edit. What I have to do is something like this:

ad_form -name myform -form {
    ...
}

set my_current_mode [ad_form_whats_my_mode -id myform]

if { $my_current_mode == "display" } {
    ad_form -extend -name myform -form {
        # Set up the form to display coumpound
        # values as a single, nicely formatted item
    }
} else {
    ad_form -extend -name myform -form {
        # Set up the form to display the same
        # items individually, each to its own row
    }
}

# Add anything else and set the action blocks
ad_form -extend -name myform -form {
    ...
} 

According to the docs "Any variables set in an -edit_request block are available to the ADP template as well as the form." But I need something that is available outside the form as you're building the form, but before you get to the ADP template. There should be an [add_form_editing_p] corresponding to [ad_form_new_p] but, since there isn't, there must be another technique.