Based on this very helpful question I'm trying to filter the display of Sprout Form entries based on the value of a form field.

For example, my form handle is 'reportHazardDeficiency' and my field name is 'company'. My template has craft.sproutForms.entries.formHandle( 'reportHazardDeficiency' ).company( 4 ) and I get

Database Exception – yii\db\Exception Unknown column 'reportHazardDeficiency.field_company' in 'where clause'

I'm running craft3 and Sprout Form trial version 3.0.0-beta.16.

  • This is a bug. We'll be fixing this soon in an upcoming release. Jul 12 '18 at 0:01

Seems to be working after upgrading to 3.0.0-beta.21. Thanks @Ben!


First, As this question is about a beta version of Sprout Forms I'd recommend updating to the latest version as we are actively fixing several minor issues as we work toward a stable release.

More generally, Form Entries support searching for a value via a custom field, however, I think the issue you may be running into relates to Related Entries vs Custom Fields that store their data in the content columns.

You can use syntax like you've shared to query a custom text field:

{% set entries = craft.sproutForms.entries
  .customField("hello") %}

For relations fields, using the relatedTo parameter performs a search for relationships:

{% set entries = craft.sproutForms.entries
  .relatedTo(4) %}
  • Using .relatedTo will be useful in future ‘has this report been assigned yet’ queries but right now the form’s company field is hidden with value = company’s id. Will look into moving from beta to stable release, thanks. Jul 18 '18 at 15:36
  • 1
    FYI (and to overstep my boundaries): if you move clause (ie 'reportHazardDeficiency'.'field_company'='4') out of subquery where and to outer where it would work. Jul 18 '18 at 16:01
  • I see, so it's not a related value it's just a text value. We can review what we're doing in that query and see if we can adjust that clause. We definitely want to support the search syntax you're going for with text values. I'll update this thread after we've had a chance to review. Jul 18 '18 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.