%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-% $m->callback( Name => $Name, CustomField => $CustomField );
+% $m->callback( Name => $Name, CustomField => $CustomField, Default => \$Default );
+% $Default = "" unless defined $Default;
% if ($CustomField->Type =~ /Select/i) {
% my $values = $CustomField->Values;
<select name="<%$Name%>">
<option value="" selected="selected">-</option>
<option value="NULL"><&|/l&>(no value)</&></option>
% while (my $value = $values->Next) {
-<option value="<%$value->Name%>"><%$value->Name%></option>
+<option value="<%$value->Name%>"<% ($value->Name eq $Default) ? q[ selected="selected"] : ''%>><%$value->Name%></option>
% }
</select>
-% }
-% elsif ( $CustomField->Type eq 'Autocomplete' ) {
-<input type="text" id="CF-<% $CustomField->id %>" name="<% $Name %>" size="20" />
+% } elsif ($CustomField->Type =~ /^Date(Time)?$/) {
+<& /Elements/SelectDate, ShowTime => ($1 ? 1 : 0), Name => $Name, Value => $Default &>
+% } elsif ( $CustomField->Type eq 'Autocomplete' ) {
+<input type="text" id="CF-<% $CustomField->id %>" name="<% $Name %>" size="20" value="<% $Default %>" />
<script type="text/javascript">
% my @options;
% my $values = $CustomField->Values;
jQuery('#'+'CF-' + <% $CustomField->id %>).autocomplete({ source: <% JSON::to_json(\@options) |n %> });
</script>
% } else {
-<input name="<%$Name%>" size="20" />
+<input name="<%$Name%>" size="20" value="<% $Default %>" type="text" />
% }
<%args>
$Name => undef
-$CustomField =>undef
+$CustomField => undef
+$Default => undef
</%args>