3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 %# (Except where explictly superceded by other copyright notices)
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 %# General Public License for more details.
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
24 <& /Elements/ListActions, actions => \@results &>
27 <FORM METHOD=POST ACTION="CustomField.html">
28 <INPUT TYPE=HIDDEN NAME="CustomField" VALUE="<%$id %>">
29 <INPUT TYPE=HIDDEN name="Queue" value="<%$Queue%>">
31 <TABLE WIDTH="100%" BORDER="0">
32 <TR><TD ALIGN="RIGHT">
35 <input name="Name" VALUE="<%$CustomFieldObj->Name%>" SIZE=20>
37 <TR><TD ALIGN="RIGHT">
38 <&|/l&>Description</&>:
40 <input name="Description" VALUE="<%$CustomFieldObj->Description%>" SIZE=80>
42 <TR><TD ALIGN="RIGHT">
45 <& /Admin/Elements/SelectCustomFieldType, Name => "Type", Default => $CustomFieldObj->Type &>
49 <INPUT TYPE=HIDDEN NAME="SetEnabled" VALUE="1">
50 <INPUT TYPE=CHECKBOX NAME="Enabled" VALUE="1" <%$EnabledChecked%>> <&|/l&>Enabled (Unchecking this box disables this custom field)</&>
55 % if ($CustomFieldObj->Id and $CustomFieldObj->Type =~ /Select/) {
56 <h2><&|/l&>Values</&></h2>
58 <& /Admin/Elements/EditCustomFieldValues, CustomField => $CustomFieldObj &>
59 <& /Admin/Elements/AddCustomFieldValue, CustomField => $CustomFieldObj &>
69 my $CustomFieldObj = RT::CustomField->new($session{'CurrentUser'});
70 my $EnabledChecked = "CHECKED";
73 if (! $CustomField ) {
74 $title = loc("Create a CustomField");
78 if ($CustomField eq 'new') {
79 my ($val, $msg) = $CustomFieldObj->Create(Queue => $Queue,
82 Description => $Description,
84 Abort(loc("Could not create CustomField", $msg)) unless ($val);
86 $CustomFieldObj->SetSortOrder($CustomFieldObj->id);
87 $title = loc('Created CustomField [_1]', $CustomFieldObj->Name());
89 $CustomFieldObj->Load($CustomField) || Abort(loc('No CustomField'));
90 $title = loc('Editing CustomField [_1]', $CustomFieldObj->Name());
92 my @aresults = ProcessCustomFieldUpdates (
93 CustomFieldObj => $CustomFieldObj,
95 push @results, @aresults;
99 $id = $CustomFieldObj->id;
101 #we're asking about enabled on the web page but really care about disabled.
102 my $Disabled = ($Enabled ? 0 : 1);
104 if ( ($SetEnabled) and ( $Disabled != $CustomFieldObj->Disabled) ) {
105 my ($code, $msg) = $CustomFieldObj->SetDisabled($Disabled);
106 push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
109 if ($CustomFieldObj->Disabled()) {
121 $CustomField => undef
123 $Description => undef