Forum OpenACS Q&A: Re: template::widget::submit is replacing the class element of html attribute on form element

Dear Jonathan,

many thanks for reporting. The issue is addressed in latest codebase

http://cvs.openacs.org/changelog/OpenACS?cs=oacs-5-10%3Aantoniop%3A20231123164735

All the best

Hi Anthony,

I tried your change but I am seeing the same problem occurring post patch.

In my debugging the element array has the html attribute which is where the classes are specified. tag_attributes is empty.

Something like this works although there is probably a simpler way

if {[info exists element(html)]} {
        # Get the named list from the html attribute
        set html_val $element(html)

        # Find if there is a class attribute in the html_value
        set class_index [string first "class" $html_val]

        # If class_index is > -1, then get the class value from the list and append prevent-double-click
        if {$class_index > -1} {
            set class_list [lindex $html_val [expr $class_index + 1]]
            lappend class_list "prevent-double-click"
            set classes [list class $class_list]
            return [input submit element [concat $tag_attributes $classes]]
        }
    }

    return [input submit element [concat $tag_attributes {class prevent-double-click}]]