template::widget::block (public)

 template::widget::block element_reference tag_attributes

Defined in packages/acs-templating/tcl/widget-procs.tcl

Widget for blocks of radio-buttoned questions

Parameters:
element_reference - Reference variable to the form element
tag_attributes - HTML attributes to add to the tag
Returns:
Form HTML for widget

Partial Call Graph (max 5 caller/called nodes):
%3 ad_decode ad_decode (public) template::widget::block template::widget::block template::widget::block->ad_decode

Testcases:
No testcase defined.
Source code:
    upvar $element_reference element

    if { [info exists element(html)] } {
        array set attributes $element(html)
    }

    if { [info exists element(value)] } {
        set value $element(value)
    } else {
        set value {}
    }

    array set attributes $tag_attributes

    set output ""
    set options $element(options)
    set count 0
    foreach option $options {
        if {$count == 0} {
            # answer descriptions in a list: {{desc1 no_of_answers} {desc2 no_of_answers} ...}
            append output "<tr align='center'><td></td><td></td>"
            foreach answer_desc $option {
                lassign $answer_desc answer_description no_of_answers
                append output "<th colspan=\"[expr {$no_of_answers + 1}]\" align=\"center\">$answer_description</th>"
            }
            append output "</tr>"
        } elseif {$count == 1} {
            append output  {<tr>}  {<td><span style="font-weight: bold">}  [ns_quotehtml [lindex $option 0]]  {</span></td>}
            foreach answer_set [lindex $option 1] {
                append output "<td>required?</td>"
                foreach answer $answer_set {
                    append output "<td>[ns_quotehtml $answer]</td>"
                }
            }
            append output {</tr>}
        } else {
            append output "<tr><td><span style=\"font-weight: bold\">[lindex $option 0]</span></td>"
            foreach question [lindex $option 1] {
                lassign $question name required_p
                append output  "<td>"  [ad_decode $required_p "t" "<span style=\"color: #f00;\">*</span>" "&nbsp;"]  "</td>"
                foreach choice [lindex $question 2] {
                    if {$choice ni $value} {
                        append output "<td><input type=\"radio\" name=\"$name\" value=\"$choice\"></td>"
                    } else {
                        append output "<td><input type=\"radio\" name=\"$name\" value=\"$choice\" checked></td>"
                    }
                }
            }
            append output "</tr>"
        }
        incr count
    }

    return "<table>$output</table>"
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
packages/acs-templating/tcl/widget-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: