Forum OpenACS Q&A: ad_form -extend suppresses -cancel_url and -edit_buttons

If I use ad_form -extend to define a form in two or more parts the -cancel_url, -cancel_label and -edit_buttons are suppressed. If I define the same form without -extend these switches take effect. Can anyone suggest how to get around this?
Hi Eric,

All I can suggest is check out this link:

http://home.galileo.edu/~miel/openACS/pdf/ad-form-quick-ref.pdf

as I find it a very useful ad_form reference.

Cheers

Collapse
Posted by Eric Lee on
I got around this by appending the submits I needed to the last last ad_form -form element in the last -extend segment:
ad_form \
      -name foo-edit \
      -has_submit {1} \
      -form { ... }

ad_form \
      -extend \
      -name foo-edit \
      -form {
      {bar:text
          ...
          {after_html "</td></tr>
          <tr class='form-element'><td colspan='2'>
          <input type='submit' name='formbutton:ok' value=' OK ' />
          <input type='submit' name='formbutton:cancel' value=' Cancel ' />"}

      }
      }

The -has_submit{1} suppresses the "OK" button that ad_form would otherwise supply. It must be in the first ad_form segment.

The form of the submit name's 'formbutton:X' is what template::form::get_button needs to return the button chosen.

For my application, I wrote a version of get_button that prefers a 'cancel' button.

An approach that didn't work was to check for the existence of different buttons ([info exists cancel]) in an -on_submit section.  It didn't work because unlike with ordinary forms, where only the submit chosen is returned, this form returns all of the submits.

Another thing that can't be done if get_button is to be used is to use regular -form elements of widget type submit because the colon in formbutton:cancel conflicts with the element name/type syntax: formbutton:cancel:text(submit)

I would still like to know whether suppression of -cancel_url and -edit_buttons is an intended effect of -extend.