[Rt-devel] [PATCH] Ticket/Create CustomField Defaults

Michael J. Pomraning mjp at securepipe.com
Wed Jun 23 09:16:59 EDT 2004


Attached patch awakens Elements/EditCustomField $Default for ticket creation.
So, CustomField-Foo=bar will default Foo's selection to "bar" (or
CustomField-2=bar, if Foo is CF #2).  Invalid CF parameters or values are
simply ignored.

Originally made against 3.0.10 -- looks like it'd apply to svn devel branch,
though.

Regards,
Mike
-------------- next part --------------
--- share/html/Ticket/Elements/EditCustomFields	2004-01-02 16:55:55.000000000 -0600
+++ local/html/Ticket/Elements/EditCustomFields	2004-06-22 22:54:19.000000000 -0500
@@ -31,7 +31,13 @@
 % my $cfcount = $CustomFields->Count;
 %  $cfcount++ if ($cfcount % 2) ; # if we have an odd number of 
 % #custom fields, fudge it so we know where to put in the table break
+%
 % while (my $CustomField = $CustomFields->Next()) {
+%
+% my $userDefault = $CFDefaults->{"CustomField-" . $CustomField->Name}
+%                     ||
+%                   $CFDefaults->{"CustomField-" . $CustomField->Id};
+%   
 % if ($cfcount == 2 * $i) {
 </table>
 </td>
@@ -44,7 +50,7 @@
       <b><%$CustomField->Name%></b><br>
       <i><%$CustomField->FriendlyType%></i>
     </td>
-    <td class="entry"><& EditCustomField, TicketObj => $TicketObj, CustomField => $CustomField, NamePrefix => $NamePrefix &></td>
+    <td class="entry"><& EditCustomField, TicketObj => $TicketObj, CustomField => $CustomField, NamePrefix => $NamePrefix, Default => $userDefault &></td>
   </tr>
 % }
 </table>
@@ -65,10 +71,9 @@
   $NamePrefix = "CustomField-";
 }
 
-
-
 </%INIT>
 <%ARGS>
 $TicketObj => undef
 $QueueObj => undef
+$CFDefaults => {}
 </%ARGS>
--- share/html/Ticket/Create.html	2004-03-10 22:22:56.000000000 -0600
+++ local/html/Ticket/Create.html	2004-06-22 08:19:36.000000000 -0500
@@ -88,7 +88,7 @@
 </TR>
 <TR>
 <TD COLSPAN=6>
-<& /Ticket/Elements/EditCustomFields, QueueObj => $QueueObj &>
+<& /Ticket/Elements/EditCustomFields, QueueObj => $QueueObj, CFDefaults => \%CFDefaults &>
 </TD>
 </TR>
 <TR>
@@ -208,6 +208,8 @@
 $QueueObj->Load($Queue) || Abort(loc("Queue could not be loaded."));
 my $CFs = $QueueObj->CustomFields();
 
+my %CFDefaults = map {$_ => $ARGS{$_}} grep {/^CustomField-./} keys %ARGS;
+
 if ($QueueObj->DefaultDueIn) {
     my $default_due = RT::Date->new($session{'CurrentUser'});
     $default_due->SetToNow();


More information about the Rt-devel mailing list