[Bps-public-commit] rt-extension-formtools branch, master, updated. 0.16-1-gad1e698

Jim Brandt jbrandt at bestpractical.com
Mon May 12 14:51:14 EDT 2014


The branch, master has been updated
       via  ad1e6989a4067dc31e9fb9b4e07e4b3bfd4a21b7 (commit)
      from  53e11cdcf27e0f871b5bd5be8847df17b36cbf5f (commit)

Summary of changes:
 html/FormTools/Field | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

- Log -----------------------------------------------------------------
commit ad1e6989a4067dc31e9fb9b4e07e4b3bfd4a21b7
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Mon May 12 14:43:59 2014 -0400

    Reset context object when attempting to load CF
    
    When attempting to load a CF, the code attempts to find a
    global CF before loading by name alone. The LoadByName CF method
    automatically sets the context object to global on that call,
    so the subsequent call in Field doesn't find non-global CFs since
    it is using the same CF object. Reset the context object to the
    ticket so the name lookup can find non-global CFs.

diff --git a/html/FormTools/Field b/html/FormTools/Field
index af51f88..6c64d66 100644
--- a/html/FormTools/Field
+++ b/html/FormTools/Field
@@ -44,7 +44,11 @@ if ( RT::Extension::FormTools::is_core_field($name) ) {
     # try loading CFs for this Queue, followed by Global, followed by any CF of given $name
     $cf->LoadByName( Name => $name, Queue => $queue->id ) if (defined $queue);
     $cf->LoadByName( Name => $name, Queue => 0 ) unless ( $cf->id );
-    $cf->LoadByName( Name => $name ) unless ( $cf->id );
+    unless ( $cf->Id ) {
+        # Reset context object to ticket because previous call made it global
+        $cf->SetContextObject($ticket) if $cf->can('SetContextObject');
+        $cf->LoadByName( Name => $name );
+    }
     unless ( $cf->id ) {
         my $msg = "Could not find a custom field called $name";
         $msg .= " for the queue ".$queue->Name if (defined $queue);

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list