The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
<select class="select-priority" name="<% $Name %>">
% unless ( defined $Default ) {
<option value="">-</option>
% }
<%PERL>
foreach my $label ( @order ) {
    my ($value, $selected);
    if ( $label eq $default_label ) {
        ($value, $selected) = ($Default, 'selected="selected"');
    } else {
        ($value, $selected) = ($map{ $label }, '');
    }
</%PERL>
<option class="<% lc $label %>" value="<% $value %>" <% $selected |n %>><% loc($label) %></option>
% }
</select>
<%ARGS>
$Name => 'Priority'
$Default => undef
$Mapping => undef
</%ARGS>
<%INIT>

my %map   = $Mapping ? %{ $Mapping } : RT->Config->Get('PriorityAsString');
my @order;
if (not $Mapping and RT->Config->Get('PriorityAsStringOrder')) {
    @order = grep {exists $map{$_}} RT->Config->Get('PriorityAsStringOrder');
} else {
    @order = sort { $map{$a} <=> $map{$b} } keys %map;
}

my $default_label = '';
if ( defined $Default && length $Default ) {
    $default_label = RT::Ticket->_PriorityAsString( $Default, \%map ) || '';
}
</%INIT>