Embperl
view release on metacpan or search on metacpan
Embperl/Form.pm view on Meta::CPAN
}
my $subfields = $subfield -> [0] ;
foreach (@$subfields)
{
$_ -> {state} = $subform -> {name} . '-show' ;
}
$subfields = $subfield -> [1] ;
foreach (@$subfields)
{
$_ -> {state} = $subform -> {name} . '-hide';
}
return {type => 'checkbox' , trigger => 1, section => $section, width => $width, name => $name, text => $text, value => $value, sublines => $subfield}
}
#------------------------------------------------------------------------------------------
#
# convert_label
#
# converts the label of a control to the text that should be outputed.
# By default does return the text or name parameter of the control.
# Can be overwritten to allow for example internationalization.
#
# in $ctrl Embperl::Form::Control object
# $name optional: name to translate, if not given take $ctrl -> {text}
#
sub convert_label
{
my ($self, $ctrl, $name, $text, $req) = @_ ;
return $text || $ctrl->{text} || $name || $ctrl->{name} ;
}
#------------------------------------------------------------------------------------------
#
# convert_options
#
# converts the values/options of a control to the text that should be outputed.
# By default does nothing.
# Can be overwritten to allow for example internationalization.
#
# in $ctrl Embperl::Form::Control object
# $values values of the control i.e. values that are submitted
# $options options of the control i.e. text that should be displayed
#
sub convert_options
{
my ($self, $ctrl, $values, $options, $req) = @_ ;
return $options ;
}
#------------------------------------------------------------------------------------------
#
# convert_text
#
# converts the text of a controls like transparent to the text that should be outputed.
# By default does nothing.
# Can be overwritten to allow for example internationalization.
#
# in $ctrl Embperl::Form::Control object
# $value value that is shown
#
sub convert_text
{
my ($self, $ctrl, $value, $text, $req) = @_ ;
return $value || $ctrl->{text} || $ctrl->{name} ;
}
#------------------------------------------------------------------------------------------
#
# diff_checkitems
#
# Takes the posted form data and the checkitems, compares them and return the
# fields that have changed
#
# in $check optional: arrayref with fieldnames that should be checked
# ret \%diff fields that have changed
#
sub diff_checkitems
{
my ($self, $check) = @_ ;
my %diff ;
my $checkitems = eval { Storable::thaw(MIME::Base64::decode ($Embperl::fdat{-checkitems})) } ;
foreach ($check?@$check:keys %Embperl::fdat)
{
next if ($_ eq '-checkitems') ;
$diff{$_} = 1 if ($checkitems -> {$_} ne $Embperl::fdat{$_}) ;
}
return \%diff ;
}
1;
__EMBPERL__
[$syntax EmbperlBlocks $]
[# ---------------------------------------------------------------------------
#
# show_form_begin - output begin of form
#]
[$ sub show_form_begin ($self, $req) $]
<script language="javascript">var doValidate = 1 ;</script>
<script src="/js/EmbperlForm.js"></script>
<script src="/js/TableCtrl.js"></script>
( run in 0.635 second using v1.01-cache-2.11-cpan-2398b32b56e )