Andreas 'ac0v' Specht > Hyper > Hyper::Control::Primitive::XSelect

Download:
Hyper-v0.05.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  1
View/Report Bugs
Module Version: v0.02   Source  

NAME ^

Hyper::Control::Primitive::XSelect - advanced and secure select control

VERSION ^

This document describes Hyper::Control::Primitive::XSelect 0.02

SYNOPSIS ^

    use Hyper::Control::Primitive::XSelect;
    my $object = Hyper::Control::Primitive::XSelect->new();

DESCRIPTION ^

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.

ATTRIBUTES ^

selected :get
deselected :get :default<[]>
deselected_value :get :default<[]>

SUBROUTINES/METHODS ^

add_element

    $object->add_element(qw(one two three));

Append elements to the elements attribute.

get_template_elements

    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).

set_elements

    $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.

set_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.

set_value

    $xselect->set_value([ 1, 2, 0 ]);

Select elements by their index.

DIAGNOSTICS ^

CONFIGURATION AND ENVIRONMENT ^

DEPENDENCIES ^

INCOMPATIBILITIES ^

BUGS AND LIMITATIONS ^

RCS INFORMATIONS ^

Last changed by

$Author: ac0v $

Id

$Id: XSelect.pm 528 2009-01-11 05:43:02Z ac0v $

Revision

$Revision: 528 $

Date

$Date: 2009-01-11 06:43:02 +0100 (So, 11 Jan 2009) $

HeadURL

$HeadURL: http://svn.hyper-framework.org/Hyper/Hyper/tags/0.05/lib/Hyper/Control/Primitive/XSelect.pm $

AUTHOR ^

Andreas Specht <ACID@cpan.org>

LICENSE AND COPYRIGHT ^

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.

syntax highlighting: