Problem/Motivation
#2853756: Consider changing the way values are flattened before passed to the CSV Encoder to provide better data per column is going to improve CSV formatting by using default field formatters to render a value.
@Berdir suggested in #2853756.5 to provide a custom a view mode in order to improve export configurability per contact form.
wondering if we want to do something like token.module. Support a contact_storage_export view mode that you can enable and configure per contact form and fall back to the default settings. Also, don't we get labels if we do it like this, or are you working around that by rendering each item separately?
See field_tokens()
Proposed resolution
Add a contact_storage_export view mode and use its configuration in ContactStorageExportService::getFormattedValue().
The view mode should be optional to enable and fall back to the current output if not set.
Think about removing date_format setting as it is going to be configurable per field.
Remaining tasks
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | contact_storage_export-2856956-9-use-export-view-mode.patch | 1.61 KB | james.williams |
Comments
Comment #2
scott_euser commentedThis sounds like an interesting idea. Part of the goal of this module is to keep it usable at a basic level without the need for configuration per form (ie, if someone creates a new form, export should just be available straight away without needing special configuration).
Would that still be the case with your proposal?
Otherwise for a more developer focused solution, as outlined in https://www.drupal.org/project/contact_storage you do have 'CSV serialization to build views to export results' listed on the project page right?
The end-user (eg, client) should still be able to:
without having to have admin access or special training.
Comment #3
scott_euser commentedAh I see Berdir's comment:
Comment #4
scott_euser commentedAt the moment this is not a priority on my list - if someone would like this feature I would be happy if someone would be willing to help with a patch.
Comment #5
steven jones commentedHere's a patch that provides an export view mode, and uses it.
This won't change the exports unless administrators also create custom settings for the export view mode for their contact forms, so keeps this module's sense of zero-configuration, whilst still allowing configuration.
Comment #7
steven jones commentedAh, that totally broke the export of non-field fields.
Here's a fix for that.
Comment #9
james.williamsRe-rolled patch. Note that these patches all depend on those in #2992265: Exported fields are in jumbled order which adds the use statement for
\Drupal\Core\Entity\Entity\EntityViewDisplay. That's probably not ideal, but I should think the two would probably usually get used together anyway.