ad_db_select_widget (public, deprecated)
ad_db_select_widget [ -size size ] [ -multiple multiple ] \ [ -default default ] [ -option_list option_list ] \ [ -blank_if_no_db blank_if_no_db ] \ [ -hidden_if_one_db hidden_if_one_db ] [ -bind bind ] \ statement_name sql_qry name
Defined in packages/acs-tcl/tcl/widgets-procs.tcl
Deprecated. Invoking this procedure generates a warning.
given a SQL query this generates a select group. If there is only one value it returns the text and a hidden variable setting that value. The first selected column should contain the optionlist items. The second selected column should contain the optionlist values.
option_list is a list in the same format (i.e. {{str val} {str2 val2}...}) which is prepended to the list
if sql_qry is null then the list is constructed from option_list only.
if there is only one item the select is not generated and the value is passed in hidden form variable.
if -multiple is given then a multi select is returned.
if -blank_if_no_db is true, then do not return a select widget unless there are rows from the database DEPRECATED: the template system offers better ways to produce markup from a query nowadays.
- Switches:
- -size (optional, defaults to
"0"
)- -multiple (optional, defaults to
"0"
)- -default (optional)
- -option_list (optional)
- -blank_if_no_db (optional, defaults to
"0"
)- -hidden_if_one_db (optional, defaults to
"0"
)- -bind (optional)
- Parameters:
- statement_name (required)
- sql_qry (required)
- name (required)
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: ad_log_deprecated proc ad_db_select_widget set retval {} set count 0 set dbcount 0 if {$option_list ne ""} { foreach opt $option_list { incr count lassign $opt value item if { (!$multiple && $value eq $default ) || ($multiple && $value in $default) } { append retval "<option selected value=\"$value\">$item</option>\n" } else { append retval "<option value=\"$value\">$item</option>\n" } } } if { $blank_if_no_db} { set count 0 } if {$sql_qry ne ""} { set columns [ns_set create] db_foreach $statement_name $sql_qry -column_set selection -bind $bind { incr count incr dbcount set item [ns_set value $selection 0] set value [ns_set value $selection 1] if { (!$multiple && $value eq $default ) || ($multiple && $value in $default) } { append retval "<option selected=\"selected\" value=\"$value\">$item</option>\n" } else { append retval "<option value=\"$value\">$item</option>\n" } } if_no_rows { if {$default ne ""} { return "<input type=\"hidden\" value=\"[ns_quotehtml $default]\" name=\"$name\">\n" } else { return {} } } } if { $count == 1 || ($dbcount == 1 && $hidden_if_one_db) } { return "$item<input type=\"hidden\" value=\"[ns_quotehtml $value]\" name=\"$name\">\n" } elseif {!$count && !$dbcount && $blank_if_no_db} { return {} } else { set select "<select name=\"$name\"" if {$size != 0} { append select " size=\"$size\"" } if {$multiple} { append select " multiple" } return "$select>\n$retval</select>" }XQL Not present: PostgreSQL, Oracle Generic XQL file: packages/acs-tcl/tcl/widgets-procs.xql