Hi there,
I want to set options in a select widget element of an ad_form accordingly with the parent category id passed.
Once the user choose the parent category the form gets refreshed and the subcategory select element get its options filled with the respective values of the children category of the parent category
Here it is the whole chunk of code that adds the parent category and subcategory elements in the ad_form
foreach {category_id category_name} [documents::get_categories -package_id $package_id] {
if {[string equal $category_name "Tipo"]} {
ad_form -extend -name document_ae -form [list \
[list "cat_${category_id}:integer(select)" \
[list label "${category_name}"] \
[list options [documents::category_get_options -parent_id $category_id]] \
[list value ""] \
[list html "onChange \"document.document_ae.__refreshing_p.value='1';document.document_ae.submit();\""]
]]
set child_id [set cat_${category_id}]
ad_form -extend -name document_ae -form [list \
[list "cat_${category_id}:integer(select)" \
[list label "[category::get_name -category_id $category_id]"] \
[list options [documents::category_get_options -parent_id $child_id] \
[list value ""] \
]]
The problem is that the page can not read the value assigned to the parent category variable,
which is the line: set child_id [set cat_${category_id}]
Furthermore i already verified if the parent category value has been passed when the form gets refreshed.
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: form:mode - edit
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: form:id - document_ae
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: __confirmed_p - 0
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: __refreshing_p - 1
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: __submit_button_name -
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: __submit_button_value -
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: __key_signature - 23 0 E1F4DE83FEE373DFDF0F67B94FFECF8F47EA3C22
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: __key - file_id
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: __new_p - 1
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: file_id - 1287
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: folder_id -
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: info2 - MESSAGE KEY MISSING: 'documents.Edit_document'
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: upload_file - solisc.gif
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: title - solisc
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: description - solisc desc
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: description.spellcheck - :nospell:
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: language - pt_BR
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: author - joao
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: coauthor - maria
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: source - fonte
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: group_id - 587
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: status - 3
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: publish_date.format - YYYY MM DD
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: publish_date.year - 2010
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: publish_date.month - 10
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: publish_date.day - 29
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: cat_1231 - 1233
[29/Oct/2010:17:42:24][21191.3061136272][-default:2-] Notice: cat_1201 - 1204
As we can see the last two lines speak for themselves. The values are there.
To certify that the variable cat_1201 is valid to the page i even added the lines:
set varname [ns_set key $myform $i]
set varvalue [ns_set value $myform $i]
as we can see at:
set myform [ns_getform]
if {[string equal "" $myform]} {
ns_log Notice "No Form was submited"
} else {
ns_log Notice "FORM"
ns_set print $myform
for {set i 0} {$i < [ns_set size $myform]} {incr i} {
set varname [ns_set key $myform $i]
set varvalue [ns_set value $myform $i]
ns_log Notice " $varname - $varvalue"
}
}
However i still get the error of "no such variable" to cat_1201
Does anyone have any idea what is wrong?