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

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 {
          {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.