Forum OpenACS Development: in HEAD packages/dynamic-types/tcl/form-procs.tcl ...

Last proc, dtype::form::edit

attempt to get value of unbound variable object_type

Collapse
Posted by Dave Bauer on
Hi Jim,

Can you provide a little context, what are you trying to do when you get this error message?

Collapse
Posted by Jim Lynch on
Heya Dave,

I'm hitting the submit button on changing the name of a form... it goes to edit_data of the form_name form which calls this proc...

The object_type var is defined in the calling frame... but what confuses me is it's not passed into the function. I guess we could upvar it, but isn't it better to pass the value into the func as a parameter?

My question REALLY is: what was the original intent as far as gaining the value of object_type for the purpose of getting it into an event which is fired off?

Collapse
Posted by Jim Lynch on
Dave,

Wouldn't it be the simplest thing to just pass object_type in, so the function which is now defined as:

ad_proc -public dtype::form::edit {
    {-form_name:required}
    {-form_id:required}
} {
    Update dynamic form name
} {
    db_dml update_form {}

    set event(object_type) $object_type
    set event(dform) $form_name
    set event(action) updated
    util::event::fire -event dtype.form event
}

would be altered so it reads like this:

ad_proc -public dtype::form::edit {
    {-form_name:required}
    {-form_id:required}
    {-object_type:required} # just this line
} {
    Update dynamic form name
} {
    db_dml update_form {}

    set event(object_type) $object_type
    set event(dform) $form_name
    set event(action) updated
    util::event::fire -event dtype.form event
}

Collapse
Posted by Dave Bauer on
Looks good to me Jim, go ahead :)
Collapse
Posted by Jim Lynch on
OK, after making that change, that error goes away and the form works most of the time. new problem: if the form name matches something in the db, it throws the usual tcl error rather than let the user know the form name is duplicated.

I'll commit this change tho.