It would be great if there was a way to use views to display a list of forms but limit (filter) the view to only show the forms that have not yet been submitted by the user. Or at least show the user which ones they have completed if they can't be filtered out. Thanks.

CommentFileSizeAuthor
#4 webform-view.txt6.17 KBtrigdog
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

Status: Active » Fixed

You should be able to do this already by adding a relationship to Webform Submissions, then add a filter for Webform Submission: SID where the SID is NULL.

quicksketch’s picture

Status: Fixed » Active

Oh, wait are you asking for an exposed filter? That may take a little more work possibly. Since this approach will generate duplicate rows for each node that has received submissions. Perhaps the Distinct option would fix that, but I doubt that would be very efficient.

trigdog’s picture

No it doesn't need to be exposed. I will try out what you suggested. Thanks!

trigdog’s picture

FileSize
6.17 KB

I still can't get this to work.
- I just created a test web form with one component (textarea) for a comment. Set it to limit 1 per user ever.
- Create two test users: testuser1 and testuser2.
- Created the attached exported view to put the block on the user's account page.
- Check to see if the block was there for testuser1 and testuser2 and it was.
- Submitted the form with testuser1 and the block was gone on testuser1's profile page. Tried to go back to the form displays the already submitted message like it should. Logged out. (Good up to this point).
- Logged in with testuser2 and went to testuser2's profile page and block was also missing even though testuser2 hasn't submitted the form yet.

I tried both setting the SID filter to is equal to NULL and is empty (NULL). I also tried logging in from a different IP with testuser2 and it still didn't display the block. Any advise is very much appreciated.

quicksketch’s picture

- Logged in with testuser2 and went to testuser2's profile page and block was also missing even though testuser2 hasn't submitted the form yet.

Ooooh, I didn't realize you wanted it *per-user* that hadn't filled out the form. I thought you just wanted a list of forms that hadn't been submitted at all by any users. You should be able to make this per-user by adding a relationship for "Webform submissions: User". That will make it so you can add a contextual filter to restrict the list just to that one user.

Hmm. Thinking on this question I'm not really sure how you would even write a SQL query to do what you want. I'm sure it's possible but my SQL knowledge is a bit rusty when it comes to excluding results like this. This would be relatively easy with a sub-query, but in Views you pretty much have to assemble this all through JOINs, which is more difficult to mentally construct.

trigdog’s picture

Thanks for the response. I tried adding that relationship earlier but it doesn't quite work because you need each form to be listed if no submission is found for the user...as it is right now, you can only use the contextual filter for UID to filter it down to the forms the user has submitted.

Basically, it needs to display the form if there are NO results with the UID contextual filter set to logged in user (an opposite effect)

I tried thinking about writing my own joins for views but I think it is beyond me right now :) This would be a great feature if anyone has the capability to create it. It also gives an alternative to the form blocks for the people who need to hide the block once the user submission limit is reached by providing a link to the forms not submitted and hiding them once they are submitted.

kurisup’s picture

+1 for this feature, I'm using webforms as a request service, offering members the chance to submit a form every six months - I was hoping to be able show a user when they could next fill in the form after every six months is up.

DanChadwick’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Closing for lack of activity. This feature is probably possible in the -4.x branch using Views.