Fix issue where trying to add a polymorphic field in search form resulted in NameError

Fixes #159
Fixes #313