Posted by dimduj on March 30, 2011 at 10:02am
5 followers
| Project: | Webform |
| Version: | 7.x-3.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | fixed |
Issue Summary
Here is a patch to get the status of a webform into views' filter.
Hope this could help.
| Attachment | Size |
|---|---|
| patch.txt | 1.18 KB |
Comments
#1
Tested and approved.
#2
#3
+ $data['webform']['table']['group'] = t('Webform infos');+
+ $data['webform']['table']['join'] = array(
+ 'node' => array(
+ 'left_field' => 'nid',
+ 'field' => 'nid',
+ ),
+ );
The name of this category should probably be just "Webform". "infos" is not a real word.
+ 'title' => t('Satus'),Should be "Status".
+ 'handler' => 'views_handler_field_numeric',We should write a custom handler for "Active" or "Inactive" to be displayed instead of 0 or 1 for the field value, just like the Node Published/Unpublished field and filter. Using the numeric handler is functional but lazy.
#4
Here's a re-roll of the original patch (edit: for 7.x-3.15). I've fixed the language issues, but haven't implemented a custom handler.
I've also changed the join to an inner join, because an outer join was unnecessary (for the query being generated).
An outer join might potentially be desirable, as no row is added to the webform table until a form component is created. However the View would need to be testing the specified value against
COALESCE(webform.status, 0)or similar for a left join to actually return those rows. A NULL webform probably shouldn't be considered equivalent to a closed webform, though.#5
edit: Oops.
#6
Ah, I had meant to set that to 7.x-3.15. I saw the 6.x-3.9 » 7.x-3.11 change in #1, didn't notice that it had been changed back in #2, and managed to just adjust the minor number without even noticing the major number. So to clarify, the original patch was for Drupal 6, and the patch in #4 is for Drupal 7.
#7
The latest patch works on both D6 and D7 without changes.
This patch needs a dedicated handler for Open/Closed status for both the field and filter. The comment module Views integration provides a pretty good example of how to do this with minimal effort.
#8
here's a patch against 6.x-3.x that includes...
#9
here's the same patch against 7.x-3.x and a view export for testing
#10
do these patches need anything else for a review?
#11
The D6 patch doesn't seem compatible with Views 2 on Drupal 6. Was this written against Views 3?
The D7 patch worked pretty well but the type (open/closed, yes/no, etc.) would always revert back to open/close when editing. I've fixed that problem in this iteration.
This patch also makes a new "Webform" group in Views, but we're currently piggy-backing off the "Node" or "Content" groups for things like the Webform Edit and Results links. I think it'd make sense to convert these all to the "Webform" group, or we can keep using the existing groups. We shouldn't split between two different locations though.
#12
Doh, apparently I just forgot to add the new files to the webform/views directory. Patch worked fine in Views 2 after that minor fix. I'll look into the minor cleanup and post an updated patch.
#13
Updated patches that simply move all the Webform fields into a common category.