Forum OpenACS Q&A: edit-display mode with ad_form

Collapse
Posted by xx xx on
Does anybody know how to use edit-display mode with ad_form? I would like to create a custom form that switches between the two modes with a button click.

It works fine when using auto-generated forms (see: display-edit demo). Even the buttons change.

But, that's the only example I found. What to do when I don't use autogenerated forms. How to change form:mode?  I'm using ad_form, so I suspect I should define a proc in -onSubmit? Does anybody have an example?

Collapse
Posted by xx xx on
Would it be a good idea to build the -form list with list calls as Jeff proposed and to use bugtracker's patch.adp/tcl as a format on how to switch between modes? Patch.adp uses the autogenerated forms, but the method seems flexibel.
Collapse
Posted by Lars Pind on
Aldert,

I'm not sure what you're trying to do.

The basic functionality is this:

- The form can be in either 'display' or 'edit' mode.

- You can set the -actions switch to your ad_form (see documentation for template::form::create) to defined the list of buttons available when in display mode.

- On both the request and submission connection, you can use template::form::get_action to find out which button was clicked while in edit mode.

Hope this helps.

/Lars

Collapse
Posted by xx xx on
I guess all I need is the 'action-button'. It wasn't in /api-doc and it turns out I needed the latest docs.
Thanks for your info and implementation.
Collapse
Posted by xx xx on
Few remarks:
- The main reason it failed was because all fields seem to be obligatory. Submit and the change between display/edit failed silently in my test formtemplate. Making them optional is easy but It took me a long time to understand.
- Furthermore the name of the submit button needs to start with "formbutton:" if you want to use: 'get_action' or 'get_button' (at least in my case).
- As far as I can see '-display_button' is not supported by ad_form. Is this because one should use '-actions' ?
Collapse
Posted by Lars Pind on
Yes, use 'actions' instead. They're equivalent.