Forum OpenACS Development: Using ad_form with manual edit/submit buttons

So I need to turn off the automatic submit buttons created using the "edit_buttons" option by using the "has_submit 1" option.

But I can't see how to then manually add a submit and an extra button which is not a submit (just a link to another page).

There doesn't seem to be any examples of what exactly to add code wise to ad_form to add a custom form button (where I can use the html option to add my own classes)

Alternatively is there any way of passing extra html to the "edit_buttons".

Reason I need all this is the bootstrap classes "btn-default" and "btn-primary" are needed for two different types of buttons. but ad_form just dumps them both out as submit buttons which go through form template and get put out as "btn-primary" in blue which is not correct. I need one primary and the other just a "btn-default" button.


ad_form -name $cookiesForm \
    -mode edit \
    -method post \
    -form {} \
    -edit_buttons [list [list "[_ CookieInfoButton]" "info" ]\
                        [list "[_ CookieContinueButton]" "continue" ]] \
This produces two "primary" buttons on form, an "info" button and a "continue" button According to template a submit button is main function so it gets class "btn-primary" and comes out blue in bootstrap but the "info" button should NOT get this primary class, it should just be the default "btn-default" class but the ad_form has them both as submit, so template sees them both as submit and adds "btn-primary" to both and get two blue buttons on form. Only want one.
Posted by Antonio Pisano on
Haven't tried, but could work: why don't you add these "non-submit" buttons as plain ad_form widgets? something like:
ad_form -name $cookiesForm \
    -mode edit \
    -method post \
    -form {
           {html {whatever attribute}}
           {value "[_ CookieInfoButton]"}
    } \
    -edit_buttons [list [list "[_ CookieContinueButton]" "continue" ]] \
Posted by Gaven Eogan on
thanks for reply. Yes that's what we tried first to do (but didn't work for some reason) so we went for temporary hack solution of using ajax calls to modify the bootstrap classes on the buttons for now.

#jQuery - only way to change classes for now
set jquery_script [subst -nocommands {
jQuery(document).ready(function() {
jQuery("[name='formbutton\\\\:info']").addClass('btn btn-default');

I will get back to this soon and try it again when I get a chance and let you know the final solution.