<select name="<% $name %>" size="<% $size %>"
% if ($multiselect) {
	multiselect="multiselect"
% }
>
% for my $option (@options) {
<option value="<%$option->[0]%>"
% 	if (defined $value && ((looks_like_number $value && looks_like_number $option->[0] && $option->[0] == $value) || $option->[0] eq $value)) {
	selected="selected"
% 	}
><%$option->[1]%></option>
% }
</select>

<%init>
use Scalar::Util qw/ looks_like_number /;

$context->add_widget(
	processor => 'process_select',
	name      => $name);

my $value = !$override && defined $ARGS{$name} ? $ARGS{$name} : $default;

$name = $context->form_id.".$name";

my @options;
if (defined $options) {
	if (ref $options eq 'HASH') {
		while (my ($key, $value) = each %$options) {
			push @options, [ $key => $value ];
		}
	} elsif (ref $options eq 'ARRAY') {
		for my $option (@$options) {
			if (ref $option eq 'HASH') {
				while (my ($key, $value) = each %$option) {
					push @options, [ $key => $value ];
				}
			} elsif (ref $option eq 'ARRAY') {
				my $key = $option->[0];
				for my $value (@{$option}[1 .. $#$option]) {
					push @options, [ $key => $value ];
				}
			} else {
				push @options, [ $option => $option ];
			}
		}
	} else {
		push @options, [ $options => $options ];
	}
}
</%init>

<%args>
$name
$size => 50
$multiselect => undef
$default => undef
$override => 0
$class
$query => undef
</%args>
