2
2
###################################################################################
4
# Embperl - Copyright (c) 1997-2005 Gerald Richter / ecos gmbh www.ecos.de
4
# Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de
5
# Embperl - Copyright (c) 2008-2012 Gerald Richter
6
7
# You may distribute under the terms of either the GNU General Public
7
8
# License or the Artistic License, as specified in the Perl README file.
22
23
use Embperl::Inline ;
25
# ------------------------------------------------------------------------------------------
27
sub get_std_control_attr
29
my ($self, $req, $id, $type, $addclass) = @_ ;
31
return $self -> SUPER::get_std_control_attr ($req, $id, $type, $type eq 'readonly'?'ef-control-number-readonly':$addclass) ;
35
# ---------------------------------------------------------------------------
37
# show_control_readonly - output the control as readonly
40
sub show_control_readonly
42
my ($self, $req, $value) = @_ ;
44
my $unit = $self->{unit} ;
45
my $unittext = $self -> form -> convert_text ($self, ($unit =~ /:/)?$unit:"unit:$unit", $unit) ;
46
$unittext =~ s/^unit:// ;
47
$value = $self -> {value} || $Embperl::fdat{$self -> {name}} if (!defined($value)) ;
48
$value .= $unittext if ($unit && $value ne '') ;
50
$self -> SUPER::show_control_readonly ($req, $value) ;
53
# ---------------------------------------------------------------------------
55
# get_validate_auto_rules - get rules for validation, in case user did
59
sub get_validate_auto_rules
61
my ($self, $req) = @_ ;
63
return [ $self -> {required}?(required => 1):(emptyok => 1), -type => 'PosInteger' ] ;
33
75
[$ sub show_control ($self)
35
77
$self->{size} ||= 10 ;
36
$self->{css_width} ||= '50%' ;
79
my $unit = $self->{unit} ;
80
my $unittext = $self -> form -> convert_text ($self, ($unit =~ /:/)?$unit:"unit:$unit", $unit) ;
81
$unittext =~ s/^unit:// ;
38
83
[- $self -> SUPER::show_control ; -]
39
[$if ($self->{unit}) $][+ $self ->{unit} +][$endif$]
84
[$if ($unit) $][+ $unittext +][$endif$]