diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index c5133c9d6a40e81df5c47406c13e6fe38565f617..279f58a3d9cdd36f41e64731e6ce70badadf54bb 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -946,9 +946,11 @@ class DynamicFormEntryAnswer extends VerySimpleModel {
     }
 
     function getSearchKeys() {
-        $val = $this->getField()->to_php($this->getValue());
+        $val = $this->getValue();
         if (is_array($val))
             return array_keys($val);
+        elseif (is_object($val) && method_exists($val, 'getId'))
+            return [$val->getId()];
 
         return [$val];
     }
diff --git a/include/class.forms.php b/include/class.forms.php
index 040cd255425d55c5a24140bbda9da0cffa463606..540cf77405b9e34dcec1240506070c3ce273c0cc 100644
--- a/include/class.forms.php
+++ b/include/class.forms.php
@@ -1105,6 +1105,10 @@ class PriorityField extends ChoiceField {
     }
 
     function to_php($value, $id=false) {
+        if (is_array($id)) {
+            reset($id);
+            $id = key($id);
+        }
         return Priority::lookup($id);
     }