Fix the Time field. Provide a getValueAsHtml method. Use it when displaying the form, so that the JS works correctly in displaying values. Fixes bug #12054 and works swell in the Thingy. The Thingy is my favorite asset now.
This commit is contained in:
parent
79ab978e49
commit
de6cf5875f
3 changed files with 60 additions and 28 deletions
|
|
@ -157,6 +157,32 @@ sub getValue {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Return the Form's value as a formatted time.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->getOriginalValue();
|
||||
my $mysqlTime = ($value =~ $mysqlFormattedDate);
|
||||
my $digits = ($value =~ /^\d+$/);
|
||||
##Format is fine
|
||||
if ( $mysqlTime ) {
|
||||
return $value;
|
||||
}
|
||||
##Convert to mysql format
|
||||
elsif ($digits) {
|
||||
return $self->session->datetime->secondsToTime($value);
|
||||
}
|
||||
else { ##Bad stuff, maynard
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 headTags ( )
|
||||
|
||||
Set the head tags for this form plugin
|
||||
|
|
@ -190,7 +216,8 @@ Renders a time field.
|
|||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->getOriginalValue;
|
||||
##JS expects formatted time
|
||||
$self->set('value', $self->getValueAsHtml);
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
$self->set("extras", $self->get('extras') . ' onkeyup="doInputCheck(document.getElementById(\''.$self->get("id").'\'),\'0123456789:\')"');
|
||||
return $self->SUPER::toHtml
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue