[rt-users] custom field type, checkboxes
Joel Schuweiler
jschuweiler at fonality.com
Tue Mar 4 13:45:45 EST 2008
Problem solved, final solution:
% my $selected = 0;
% my @category;
% my $id = $NamePrefix . $CustomField->Id;
% my $out = $m->scomp('SELF:options', %ARGS, SelectedRef =>
\$selected, CategoryRef => \@category, ID => $id);
% if (@category) {
<script type="text/javascript"
src="<%$RT::WebPath%>/NoAuth/js/cascaded.js"></script>
%# XXX - Hide this select from w3m?
<select onchange="filter_cascade('<% $id %>-Values', this.value)"
name="<%$id%>-Category">
<option value="" <% !$selected && 'SELECTED'
%>><&|/l&>-</&></option>
% foreach my $cat (@category) {
% my ($depth, $name) = @$cat;
<option value="<% $name %>"><% ' ' x $depth |n
%><%$name%></option>
% }
</select><br />
% }
%if ($CustomField->MaxValues != 0 )
%{
<select name="<%$id%>-Values" id="<%$id%>-Values"
<% $Multiple && 'MULTIPLE' %>>
<option value="" <% !$selected && 'SELECTED' %>><&|/l&>(no
value)</&></option>
% $m->out($out);
</select>
%}
%else
%{
% $m->out($out);
%}
<%ARGS>
$Object => undef
$CustomField => undef
$NamePrefix => undef
$Default => undef
$Values => undef
$Multiple => 0
$Rows => undef
</%ARGS>
<%method options>
% my $selected;
% my $CFVs = $CustomField->Values;
% my @levels;
% while ($CFVs and my $value = $CFVs->Next )
% {
% if ($CustomField->MaxValues == 0 )
% {
<input type="checkbox" style="border: none;" name="<%
$ID %>-Values" id="<%$ID%>-Values" value="<%$value->Name%>"
% if ($Values)
% {
<% $Values->HasEntry($value->Name) &&
($$SelectedRef = 1) && 'CHECKED' %>
% }
% elsif ($Default)
% {
<% (ref $Default ? (grep {$_ eq $value->Name}
@{$Default}) : ($Default eq $value->Name))
&& ($$SelectedRef = 1) && 'CHECKED' %>
% }
><% $value->Name%><br>
% }
% else
% {
<option value="<%$value->Name%>"
% if ($Values)
% {
<% $Values->HasEntry($value->Name) &&
($$SelectedRef = 1) && 'SELECTED' %>
% }
% elsif ($Default)
% {
<% (ref $Default ? (grep {$_ eq
$value->Name} @{$Default}) : ($Default eq $value->Name))
&& ($$SelectedRef = 1) && 'SELECTED' %>
% }
><% $value->Name%></option>
% }
% }
<%args>
$CustomField => undef
$Default => undef
$Values => undef
$SelectedRef => undef
$CategoryRef => undef
$ID => undef
</%args>
</%method>
More information about the rt-users
mailing list