Display CSV headers in textarea when creating a new feed

Created on 15 November 2024, 5 months ago

Problem/Motivation

In Add a CSV template feature to download a sample CSV file Needs work a feature is added to download a CSV template. This is a CSV file where on the first row the headers are already there.

It would be great if these same CSV headers are also displayed in the textarea that this module provides.

Steps to reproduce

  1. Apply the code from Add a CSV template feature to download a sample CSV file Needs work .
  2. Create a feed type with the Textarea Fetcher and the CSV parser and configure a few mappings with CSV column sources.
  3. Add a new feed.

Proposed resolution

When creating a feed, check if the selected parser implements \Drupal\feeds\Plugin\Type\Parser\ParserWithTemplateInterface and if so, call the method getTemplateContents() on it. In case of the CSV parser, that method returns the CSV headers.

Remaining tasks

  • Add test coverage
  • Review & commit

User interface changes

In the textarea on the feed form the CSV headers will be displayed when creating a new feed.

API changes

None.

Data model changes

None.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇳🇱Netherlands megachriz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024