Problem/Motivation
We need a better CSV download and submissions table for Entityforms. Views is used for this now but the problem is that these Views don't have the actual fields values in them. You can specify an alternate View for each Entityform Type(technically this is an entity bundle). The problem is that each field would have to be added manually for each View. This does not seem practical for a site that is using Entityforms to create numerous forms and possibly adding, removing and/or hiding fields on a regular basis.
Proposed resolution
I have figured out a way to use 1 View for all Entityform Types and have that View dynamically have all the fields for the Entityform Type that it is currently displaying. (Technically this is done by checking for all the fields attached to the Bundle and then adding them in hook_views_pre_view)
Remaining tasks
I will upload the initial patch below. It will need to be tested. You will have to revert the provided submission View if you are using on an existing site. Please also provide feedback on the feature it provides. The CSV download needs Views Data Export to be enabled. It can also provide downloads in other formats.
I am looking to keep this functionality rather simple and have advanced use cases be handled by using other existing module that can modify the View.
Alternative Method
The other option for this feature would be to create a separate module called "Views Auto Fields" that would add a Views settings that would add this functionality to any Entity Bundle based View. The setting would be something like "Add all Fields that attached to the specified Entity Bundle. This could either be required or optional module for Entityforms. I am not sure if this feature would actually be useful in other cases but could applied to any View that shows only entities from a specific bundle of a fieldable Entity. Let me know if you think this would useful as a stand-alone module.
User interface changes
This would remove the need to use different Views for different EntityForm Types. Therefore I would remove option to specify a different default submissions View and the option to change the View for each EntityForm Type.
It would still be possible to change the View used for EntityForm submissions by cloning and disabling the default View.
Original report by tedbow
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | entityform-create_autofield_views-1657956-4.patch | 46.58 KB | tedbow |
| #3 | entityform-create_autofield_views-1657956-3.patch | 41.91 KB | tedbow |
| #2 | entityform-create_autofield_views-1657956-2.patch | 41.93 KB | tedbow |
| #1 | entityform-create_autofield_views-1657956-1.patch | 27.95 KB | tedbow |
Comments
Comment #1
tedbowOk, initial patch. Any feedback appreciated.
UPDATE: This also provides XML downloads if you have "Views Data Export" installed.
Comment #2
tedbowUpdate patch:
Changes:
Comment #3
tedbowUpdated patch removed call to "dpm"
Comment #4
tedbowOk, This update puts back the option for the admin to set the default View for entityform submissions.
It also allows overriding submissions View per Entityform Type.
The Views that are used to override should follow some rules to take advantage of the functionality.
An update to #2 above the entity Views Mode mention will now also control the format display used for the Fields automatically added to the View.
Comment #5
kristen polThis sounds awesome. Not sure if there should be a separate module or not. One concern would be how the page looks when you have lots of fields. I hope to try the patch soon!
Comment #6
tedbowI have committed this to the dev version. I am going to mark this as fixed. The module is still in alpha phase so I imagine this will be revisited at another time but I think it is major improvement from what was there previously.
To get the most out of this feature you should have these two module.
Views Data Export
View Bulk Operations
These aren't required for the module because I think some people will not need these features. If you install these features after installing Entityforms you will have to revert the default View.
Comment #7
tedbowmarking as fixed
Comment #8
mrfelton commentedCool. We do actually have a use case for a module that can add all filelds from a bundle to a view. A custom entity type (created using eck) that is for collecting 'newsletter subscription requests'. Additional 'newsletter types' can be created by creating new bundles. And additional data can be collected as part of the newsletter by adding new fields to the bundle. Another module extends this by providing download functionality, also using views_data_export. So, the ability to automatically have these fields added to the data exports, this functionality would remove the requirement to have to create new export views to go with new newsletter types. Actually, this newsletter module does a very similar thing to what entityforms does.
I can think of other uses cases too, such as in the Registration Entity module where the admin views could possibly be enhanced and simplified. Would be quite nice to separate this.