Forum OpenACS Development: Re: implementing view/add/edit page with ad_form

Collapse
Posted by Don Baccus on
"This doesn't make a whole lot of sense to me. If you're entering new data, most of the time you won't have a pre-allocated value for the key field so you won't be able to call ad_form_new_p at all."

Huh? What makes you say that, the code does this:

set form [ns_getform]

    return [expr {[empty_string_p $form] || [ns_set find $form $key] == -1 || [ns_set get $form __ne
w_p] == 1 }]

It checks to see that you DON'T have a pre-allocated value, that's HOW it determines that it's a new form rather than edit form. The second check for __new_p has to do with the refreshing mode associated with javascript widgets IIRC (it's been over two years since I wrote it).

Are you sure you're passing the right key value, and that you declared it "optional" rather than give it a default value in ad_page_contract?