Hyper::Control::Primitive::XSelect - advanced and secure select control
This document describes Hyper::Control::Primitive::XSelect 0.02
use Hyper::Control::Primitive::XSelect; my $object = Hyper::Control::Primitive::XSelect->new();
Primitive Control for Selects which enables you to select objects and other complex data structures - not only the value from the selected elements which is used with standard cgi forms.
Another important thing of the XSelect is that users can not inject unknown elements (e.g. add and choose an element, which is not listed). So forms which uses the XSelect are more secure than others cause you don't need to keep care for injected elements.
$object->add_element(qw(one two three));
Append elements to the elements attribute.
my $template_elements_ref = $xselect->get_template_elements(); # [ # { data => $element, value => 0, is_selected => 0, }, # { data => $element, value => 1, is_selected => 1, }, # ... # ]
Used in Templates for getting all collected element info as array ref with some hash ref structures. The key value is the element's index (security reasons).
$xselect->set_elements([ $object1, $object2, $object3]); # or $xselect->set_elements([ $hash_ref1, $hash_ref2 ]); # or $xselect->set_elements([ qw(a b c) ]);
Set elements which should could be selected.
$xselect->set_selected([ $object1, $object2 ]); # or $xselect->set_selected([ qw(a c) ]);
Set selected by passing the original Objects or the original scalar values. Elements will be selected in ordered data mode.
$xselect->set_selected(sub { 'a' eq $_[0] });
You can also call set_selected with a code reference. The code reference is called for each element of the XSelect and has to return a true value if the element is selected.
$xselect->set_value([ 1, 2, 0 ]);
Select elements by their index.
version
Class::Std::Storable
Hyper::Control::Base::BSelect
Hyper::Functions
Scalar::Util
$Author: ac0v $
$Id: XSelect.pm 528 2009-01-11 05:43:02Z ac0v $
$Revision: 528 $
$Date: 2009-01-11 06:43:02 +0100 (So, 11 Jan 2009) $
$HeadURL: http://svn.hyper-framework.org/Hyper/Hyper/tags/0.05/lib/Hyper/Control/Primitive/XSelect.pm $
Andreas Specht <ACID@cpan.org>
<ACID@cpan.org>
Copyright (c) 2009, Andreas Specht <ACID@cpan.org>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Hyper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Hyper
CPAN shell
perl -MCPAN -e shell install Hyper
For more information on module installation, please visit the detailed CPAN module installation guide.