Class ::xowiki::formfield::bootstrap-select
::xowiki::formfield::bootstrap-select
create ...
Class Relations
- class: ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- superclass: ::xowiki::formfield::select
![[i]](/resources/acs-subsite/ZoomIn16.gif)
::xotcl::Class create ::xowiki::formfield::bootstrap-select \
-superclass ::xowiki::formfield::select
Methods (to be applied on instances)
initialize (scripted)
next
::xo::Page requireCSS "https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css"
template::add_script -order 20 -src "https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js"
security::csp::require script-src https://cdn.jsdelivr.net
security::csp::require style-src https://cdn.jsdelivr.net
render_input (scripted)
set value [:value]
set :CSSclass "selectpicker form-control"
set atts [:get_attributes id name data-live-search {CSSclass class} {placeholder title}]
set disabled_p [:is_disabled]
if {$disabled_p} {lappend atts disabled true}
if {${:multiple}} {lappend atts multiple ${:multiple}}
if {!${:required}} {
set :options [linsert ${:options} 0 [list "--" ""]]
set :descriptions [linsert ${:descriptions} 0 ""]
}
if {[llength ${:options}] != [llength ${:descriptions}]} {
error "incorrect number of descriptions provided ([llength ${:descriptions}]): must be [llength ${:options}]"
}
::html::select $atts {
foreach o ${:options} d ${:descriptions} {
lassign $o label rep
set :opt_description $d
set atts [:get_attributes {opt_description data-subtext}]
if {$disabled_p} {lappend atts disabled true}
lappend atts value $rep
if {$rep in $value} {
lappend atts selected selected
}
::html::option $atts {::html::t $label}
::html::t \n
}
}
:handle_transmit_always $value