Forum OpenACS Q&A: Re: Tutorial package confusion

Collapse
Posted by Harish Krishnan on
Joe,there is nothing wrong with the procedure. An item_id should be provided to the mfp::note::add call. The item_id is created by the ad_form procedure. In the ad_form constructed on the note-edit.tcl page the item_id is set by " {item_id:key}". The key is dynamically generated from the sequence acs_object_id_seq. Check the ad_form documentation [1] for further reading.
In the end the item_id should be available when the form is submitted when creating a new note.

[1] https://openacs.org/api-doc/proc-view?proc=ad%5fform

Collapse
Posted by Joe Cooper on
Thanks for the pointer to the ad_form docs, Harish. Very useful. I had been reading about the old form generator procedures...ad_form looks much nicer.

Since the item_id is required (and should be), my question becomes, "Why was the tutorial and test case written without the item_id included in the call to mfp::note::add?" Was there a time when this variable magically followed the object around? I'm an utter newbie to both OACS and TCL, so forgive me if I'm being daft...I'm just trying to wrap my head around the design of OACS so I can get started on some simple apps of my own.

On a related note, since the :key needs to get passed around when dealing with ad_forms, how does one write a test case for an ad_form procedure. A grep of the test directories in the current OACS version turns up no obvious cases of ad_form tests. Can someone point me to a test suite that includes tests for ad_form procedures?

Specifically, I guess just a pointer for how to fix the provided test case in the tutorial so that it can pass the item_id would be sufficient to make the test tutorial make sense.