Forum OpenACS Q&A: ad_form extend

Collapse
Posted by Jason Cheung on
I seem to have a small problem with extend switch in ad_form, why is the following giving me an error?

---------------------------------------------
ad_form -name form_name -mode edit -cancel_url $return_url -cancel_label "Cancel" -html { enctype multipart/form-data } \
-export { group_id } -form {

item_id:key
}

ad_form -extend -name form_name -form {

{article_title:text,nospell {section "$title"}
{label "標題"}
{html {size 40}}}

} -select_query_name get_article -validate {

# Must fufill below setting...
{article_title
{[string length $article_title] < 500}
"Title must be a string containing less then 500 characters"
}

} -new_data {
---------------------------------------------
Key "item_id" has the value "104521" but no select_query, select_query_name, or edit_request clause exists. (This can be caused by having ad_form request blocks in the wrong order.)
while executing
"ad_form -name form_name -mode edit -cancel_url $return_url -cancel_label "Cancel" -html { enctype multipart/form-data } -export { group_id } -form {
..."

whereas if I just removed the line 'ad_form -extend -name form_name -form {' it works fine, everything else being the same? I am positive I have my select_query immediately after the form creation blocks. I have never had this problem with all my other ad_forms.

Thanks,

Jason

Collapse
2: Re: ad_form extend (response to 1)
Posted by Jason Cheung on
Similiarly trying ad_form -extend -name form_name -select_query_name get_article -validate {

gives me the same error .. must be some syntax error .. :(

Collapse
3: Re: ad_form extend (response to 1)
Posted by Jason Cheung on
still having this problem .. anyone able to give some lead?

thanks in advance

Collapse
4: Re: Re: ad_form extend (response to 3)
Posted by Jason Cheung on
it seems

-cancel_url $return_url \
-cancel_label "Cancel" \

was the problem .. removing them seems to have fixed the error ... not sure why having these 2 lines would mess up the ad_form block structure

Collapse
5: Re: ad_form extend (response to 1)
Posted by Brian Fenton on
I've just come across this problem too. I have an ad_form block with an extend that was working fine. When I add this to my ad_form:
-cancel_url $return_url \
-cancel_label $cancel_label \

I get the following error:
No "form" block has been specified for form "ReportForm"
while executing
"ad_form -name $form_id -method get -mode $form_mode -has_edit 1 -cancel_url $return_url -cancel_label cancel_label -export {ticket_id}"

Does anyone have a solution for this?

thanks
Brian

Collapse
6: Re: ad_form extend (response to 5)
Posted by Ryan Gallimore on
Hi Brian,

ad_form must include a -form switch, even if it is empty.

Try adding -form {} to the call.

Collapse
7: Re: ad_form extend (response to 6)
Posted by Brian Fenton on
Thanks Ryan. Now that is strange. As I said, everything was working perfectly until I added the -cancel_url. I didn't have a -form block in the initial form definition, and it was working fine.

Doing what you suggest, I'm now getting this error:
Key "report_id" has the value "724" but no select_query, select_query_name, or edit_request clause exists. (This can be caused by having ad_form request blocks in the wrong order.)
while executing
"ad_form -name $form_id -method get -mode $form_mode -has_edit 1 -cancel_url $return_url -cancel_label $cancel_label -export {ticket_id} -form {..."
("uplevel" body line 118)

The thing is, I DO have a select_query block in one of my extend blocks. So this has me totally confused.

So am I doing something wrong, or is this a bug in ad_form?