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 (required)
Reference variable to the form element
tag_attributes (required)
HTML attributes to add to the tag
Returns:
Form HTML for widget

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

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

    array set attributes  [::template::widget::merge_tag_attributes element $tag_attributes]

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

    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>"  [expr {$required_p eq "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: