Forum OpenACS Q&A: -edit_buttons and <formwidget>

Collapse
Posted by Thomas Blanchin on
Hi all.

I'm trying to have a cutom form with several buttons (Ok, Cancel, Email).
I use edit_buttons to have those buttons and get_button to know which one has been pressed.

Now, for "human" aspect, I would like to separate the Email button from the other ones.
I tried to create my form in the adp with <formtemplate> and <formwidget>, but it doesn't recognise the id of my buttons :

tcl :
-edit_buttons {{"ok" ok} {"Email" email}}

adp :
<formwidget id="ok">

result :
Element "ok" does not exist in form "files"

Any idea appreciated.
Merry Christmas.

Collapse
Posted by Claudio Pasolini on
I had a similar problem and, not having time to investigate, found a workaround using the basic templating system:
  • define the butttons at the end of ad_form with commands like:
    element create lineaddedit new_keep -label "Crea e mantieni"   -widget submit -datatype text
    element create lineaddedit new_clear -label "Crea e azzera" -widget submit -datatype text
    element create lineaddedit clear -label "Azzera" -widget submit -datatype text
    
  • place the form widgets as you like referencing their id
Collapse
Posted by Thomas Blanchin on
Thanks for the answer Claudio.

Are you sure it's possible to catch which button has been pressed by the user with this technic ?

Outside my ad_form, I have :

element create files ok -label "OK" -widget submit -datatype text
element create files cancel -label "Cancel" -widget submit -datatype text
element create files email -label "Email" -widget submit -datatype text

and in -after_submit :

if { [template::form get_button "files"] eq "email" } {
ad_returnredirect \
[export_vars -base attachment_email]
}

but I'm not correcly redirected when pressing the "Email" button.
I tried putting the "element create" in the -edit_request, but no change.

Thanks.

Collapse
Posted by Claudio Pasolini on
Hi Thomas,

I don't remember if I had trouble using 'template::form get_button', but my program actually simply uses this to check the button pressed:

    if {[info exists new_keep]} {
        # send a new screen with the data just inserted
        ad_returnredirect "lines?item_id=$item_id&keep_id=$line_id"
    }
and works pretty well.