template::widget::textdate (public)

 template::widget::textdate element_reference tag_attributes

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

Implements the textdate widget.

Parameters:
element_reference (required)
tag_attributes (required)

Partial Call Graph (max 5 caller/called nodes):
%3 template::add_event_listener template::add_event_listener (public) template::head::add_javascript template::head::add_javascript (public) template::util::textdate_localized_format template::util::textdate_localized_format (public) template::widget::input template::widget::input (public) template::widget::textdate template::widget::textdate template::widget::textdate->template::add_event_listener template::widget::textdate->template::head::add_javascript template::widget::textdate->template::util::textdate_localized_format template::widget::textdate->template::widget::input

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

    set date_valid_p 0
    if { [info exists element(value)] } {
        set textdate $element(value)
        if { [regexp {^([0-9]{4})-([0-9]{2})-([0-9]{2})$} $textdate match year month day] } {
            set date_valid_p [string is false [catch { clock scan "${textdate}" }]]
            # we have a correctly formatted iso date that we
            # can reformat for display, we don't use lc_time_fmt
            # because it could fail and cause a server error.
            # The date may be formatted correctly but it may be
            # an invalid date (which is caught by
            # template::data::validate::textdate) so we need to
            # re-format the input into the format the user specified
            # by this means
            set textdate [template::util::textdate_localized_format]
            regsub {yyyy} $textdate $year textdate
            regsub {mm} $textdate $month textdate
            regsub {dd} $textdate $day textdate
        }
    } else {
        set textdate ""
    }

    if { $date_valid_p } {
        set javascriptdate $textdate
    } else {
        set javascriptdate ""
    }

    if {$element(mode) eq "edit"} {
        set id $element(id)_input_field
        append output [subst {
            <input type="text" name="$element(id)" size="10" maxlength="10" id="$id" value="[ns_quotehtml $textdate]">
            <input type="button" style="border-width: 0px; height: 17px; width: 19px; background-image: url('/resources/acs-templating/calendar.gif'); background-repeat: no-repeat; cursor: pointer;" id="$id-control">
        }]

        ::template::head::add_javascript  -src /resources/acs-templating/calendar.js

        template::add_event_listener  -id $id-control  -script [subst {
                showCalendarWithDefault('$element(id)_input_field', '$javascriptdate', '[template::util::textdate_localized_format]');
            }]
    } else {
        append output $textdate [subst {<input type="hidden" name="$element(id)" value="[ns_quotehtml $textdate]">}]
    }

    return $output
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: