%# Xerox does it again and again and again and ...
% my @entry_fields;
% while (my $CustomField = $CustomFields->Next()) {
%   if ($CustomField->IsEntry) {
%     push @entry_fields, $CustomField;
%     next;
%   }
% my $Values = $TicketObj->CustomFieldValues($CustomField->id);

<%$CustomField->Name%> - <%loc($CustomField->Type)%><br>
% if ($CustomField->Type =~ /^Freeform(?:Single|Date|Time|Number)$/) {
<input name="Ticket-<%$TicketObj->Id%>-CustomField-<%$CustomField->Id%>-Value"
       value="<%$Values->Count ? $Values->First->Content : ''%>">
% } elsif ($CustomField->Type eq 'FreeformMultiple') {
<textarea name="Ticket-<%$TicketObj->Id%>-CustomField-<%$CustomField->Id%>-Values">
%while (my $value = $Values->Next ) {
<%$value->Content%>
%}
</textarea>
% } elsif ($CustomField->Type =~ /^Select/) {
<select name="Ticket-<%$TicketObj->Id%>-CustomField-<%$CustomField->Id%>-Values"
        size="5"
        <%$CustomField->Type eq 'SelectMultiple' && 'MULTIPLE'%>
        >
% my $CustomFieldValues = $CustomField->Values();
% my $selected;
% while (my $value = $CustomFieldValues->Next) {
<option value="<%$value->Name%>" 
        <% $Values->HasEntry($value->Name) && ($selected = 1) && 'SELECTED' %>
        ><% $value->Name%></option>
% }
<option value="" <% !$selected && 'SELECTED' %>><&|/l&>(no value)</&></option>
</select>
% }
<br>
% }

% if (@entry_fields) {
<& /Ticket/Elements/EditCustomFieldEntries, Prefix => 'AddEntry-', CustomFields => \@entry_fields, TicketObj => $TicketObj &>
% }

<%INIT>
my $CustomFields = $TicketObj->QueueObj->CustomFields();
</%INIT>
<%ARGS>
$TicketObj => undef
</%ARGS>
