The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

HTML::Widget::Plugin::Select - a widget for selection from a list

VERSION

version 0.204

SYNOPSIS

  $widget_factory->select({
    id      => 'the-selector', # if no name attr given, defaults to id value
    value   => 10,
    options => [
      [  0 => "Zero" ],
      [  5 => "Five" ],
      [ 10 => "Ten"  ],
    ],
  });

DESCRIPTION

This plugin provides a select-from-list widget.

The default_classes attribute may be used to add a default class to every produced input. This class cannot be overridden.

  my $plugin = HTML::Widget::Factory::Input->new({
    default_classes => [ qw(foo bar) ],
  });

METHODS

provided_widgets

This plugin provides the following widgets: select

select

This method returns a select-from-list widget.

In addition to the generic HTML::Widget::Plugin attributes, the following are valid arguments:

disabled

If true, this option indicates that the select widget can't be changed by the user.

ignore_invalid

If this is given and true, an invalid value is ignored instead of throwing an exception.

options

This may be an arrayref of arrayrefs, each containing a value/name/option tuple, or it may be a hashref of values and names.

Use the array form if you need multiple entries for a single value or if order is important, or to provide per-select-option options. The only valid option is disabled.

value

If this argument is given, the option with this value will be pre-selected in the widget's initial state.

An exception will be thrown if more or less than one of the provided options has this value.

build

 my $widget = $class->build($factory, \%arg)

This method does the actual construction of the widget based on the args set up in the exported widget-constructing call. It's here for subclasses to exploit.

make_option

  my $option = $class->make_option($factory, $value, $name, $arg, $opt_arg);

This method constructs the HTML::Element option element that will represent one of the options that may be put into the select box. This method is likely to be refactored in the future, and its arguments may change.

validate_value

This method checks whether the given value option is valid. See "select" for an explanation of its default rules.

AUTHOR

Ricardo SIGNES

COPYRIGHT AND LICENSE

This software is copyright (c) 2005 by Ricardo SIGNES.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.