Hi Antonio,
I see your fix and it does work. A couple of questions :
template::widget::merge_tag_attributes
, is removing the element(html) is an expected behavior. Add to procedure documentation
template::widget::input type element_reference tag_attributes
- is procedure expecting the element(html) to be empty?
One of the solutions we tested is to pass the tag_attributes
dictionary along with the element parameters, instead of using the attributes
dictionary. This works on the assumption that template::widget::input will handle the merging html tags when building the widget. This works for the h5time, widget. Also, the code for template::widget::radio_text
and template::widget::checkbox_text
calls template::widget::input
(both widgets do not have the duplicate value) with the tag_attributes
instead of the attributes.
See the proposed changes "-->"
ad_proc -public template::widget::h5date {
...
} {
upvar $element_reference element
set attributes \
[::template::widget::merge_tag_attributes element $tag_attributes]
# Add fallback pattern attribute. Note that this pattern won't
# account for leap years or invalid days of the month. We leave
# this fine-graned validation to the server-side for now.
--> dict set tag_attributes pattern {[0-9]+-(1[0-2]|0[0-9])-(3[0-1]|[0-2][0-9])}
# check min/max constraint
set last_date ""
foreach d {max value min} {
if {[info exists element($d)] && $element($d) ne ""} {
set attr_value $element($d)
} elseif {[dict exists attributes $d] && [dict get $attributes $d] ne ""} {
set attr_value [dict get $attributes $d]
} else {
continue
}
set invalid_date_p [catch {
set current_date [clock scan $attr_value -format "%Y-%m-%d"]
}]
if {!$invalid_date_p} {
if {$last_date ne "" &&
$current_date > $last_date} {
ns_log Warning "template::widget::h5date value of attribute \"$d\" $attr_value too big"
} else {
--> dict set tag_attributes $d $attr_value
}
set last_date $current_date
} else {
ns_log Warning "template::widget::h5date value of attribute \"$d\" $attr_value is not a correct date"
}
}
if {[info exists element(step)]} {
if {[string is integer -strict $element(step)]} {
--> dict set tag_attributes step $element(step)
} else {
ns_log Warning {template::widget::h5date value of attribute "step" is not an integer!}
}
}
--> return [template::widget::input date element $tag_attributes]