| HTML::GUI::select - Create and control a select input for webapp |
HTML::GUI::select - Create and control a select input for webapp
Version 0.01
The select widget is made for choose an item in limited list.
parameter :
the newValue (scalar) to test
=cut
sub isNewValue($$)
{
my ($this,$newValue) = @_;
foreach my $option (@{$this->{options}}){
if ($newValue eq $option->{value}){
return 0;
}
}
return 1;
}
Description :
Define the options of the select box.
parameters :
$options is a ref to an array of hash ref
[{ value => "myvalue",
label => "my label},
{ value => "myvalue2",
label => "my second label}]
=cut
sub setOptions { my ($this,$options) = @_; if (!$options || ref $options ne 'ARRAY'){ $this->error("priv",{ type=>'incorrect use of API', 'explanation' => '$option should be an ARRAY ref', option => $options});
}
foreach my $oneOption (@$options){
if (ref $oneOption ne "HASH"
|| !exists $oneOption->{value}
|| !exists $oneOption->{label}){
#wrong data structure !!
$this->error("priv",{
type=>'incorrect use of API',
'explanation' => '$oneOption should be a hash ref '
.'with ˝value" and "label" keys',
option => $oneOption});
next;
}
$oneOption->{value} ||= '';
$oneOption->{label} ||= '';
if (!$this->isNewValue($oneOption->{value}) ){
#value already used !!!
$this->error("priv",{
type=>'incorrect use of API',
'explanation' => 'the value of $oneOption is already '
.'present in the widget',
option => $oneOption});
next;
}
push @{$this->{options}} , $oneOption;
}
}
This method is the specialisation of the widget.pm method, refer to the widget.pm manual for more information.
Description :
Return the html of the widget to be inserted in a <p> tag or a a table.
Jean-Christian Hassler, <jhassler at free.fr>
Please report any bugs or feature requests to
bug-gui-libhtml-select at rt.cpan.org, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc HTML::GUI::widget
You can also look for information at:
Copyright 2007 Jean-Christian Hassler, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| HTML::GUI::select - Create and control a select input for webapp |