Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#4 | webform-view.txt | 6.17 KB | trigdog |
Comments
Comment #1
quicksketchYou 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.
Comment #2
quicksketchOh, 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.
Comment #3
trigdog CreditAttribution: trigdog commentedNo it doesn't need to be exposed. I will try out what you suggested. Thanks!
Comment #4
trigdog CreditAttribution: trigdog commentedI 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.
Comment #5
quicksketchOoooh, 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.
Comment #6
trigdog CreditAttribution: trigdog commentedThanks 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.
Comment #7
kurisup CreditAttribution: kurisup commented+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.
Comment #8
DanChadwick CreditAttribution: DanChadwick commentedClosing for lack of activity. This feature is probably possible in the -4.x branch using Views.