NAME

Form::Factory::Control::SelectMany - the multi-select control

VERSION

version 0.006

SYNOPSIS

has_control pick_some => (
    control => 'select_many',
    options => {
        label => 'Just select some of these already...",
        available_choices => [
            Form::Factory::Control::Choice->new('one');
            Form::Factory::Control::Choice->new('two');
            Form::Factory::Control::Choice->new('three');
        ],
        default_selected_choices => [ qw( one three ) ],
    },
);

DESCRIPTION

A select many can be displayed as a multi-select list box or a list of checkboxes.

This control implements Form::Factory::Control, Form::Factory::Control::Role::AvailableChoices, Form::Factory::Control::Role::Labeled, Form::Factory::Control::Role::ListValue.

ATTRIBUTES

selected_choices

This is a list of currently selected choices.

default_choices

This s a list of the default selection.

stashable_keys

The "selected_choices" are stashed.

METHODS

current_values

Returns the "selected_choices", if set. Failing that, it returns the "default_selected_choices", if set. Failnig that, it returns an empty list.

is_choice_selected

for my $choice (@{ $self->available_choices }) {
    if ($control->is_choice_selected($choice)) {
        # ...
    }
}

This is a helper that is useful while iterating over the available choices in deciding which have been selected.

AUTHOR

Andrew Sterling Hanenkamp <hanenkamp@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2009 Qubling Software LLC.

This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.