backdrop-contrib / webform_import

Allows delimited data files to be imported as submission (results) into webforms.
GNU General Public License v2.0
0 stars 2 forks source link

Many fields not importing #4

Closed leeksoup closed 9 months ago

leeksoup commented 1 year ago

I did see that IP and user-ID not importing was reported previously in issue #2 and fixed, but I'm still having problems with importing several fields.

I exported (Downloaded) some data from my live site, and am trying to import it to my dev site. I exported using "Form Key" for the column header format, and otherwise default settings.

I then imported the file (on the dev site) using "Field Form Keys" for the Column header contains value, otherwise default. The first try, I got an error on the 2 header lines, so I deleted those and then imported again the same way.

I get the following warnings, and indeed, those fields aren't imported. Help? image

I'm not sure why the import / upload doesn't recognize the same form keys that the export / download puts into the file.

leeksoup commented 1 year ago

I took a look in the code where the "components" are defined, and it looks to me like those key names don't match the ones in the CSV download / export. E.g.

function webform_import_csvtemplate($node, $type) {
  $types = _webform_import_field_key_options();
  $filename = check_plain($node->title) . '_upload.csv';
  $headers = array();
  $node->webform['components']['-1'] = array(
    'name' => 'Submission ID',
    'form_key' => 'SID',
  );
  $node->webform['components']['-2'] = array(
    'name' => 'UID',
    'form_key' => 'UID',
  );
  $node->webform['components']['-3'] = array(
    'name' => 'IP Address',
    'form_key' => 'IP_ADDRESS',
  );

Rather than what is exported to the CSV, which is (for these fields): webform_sid, webform_uid, and webform_ip_address.

OK, I do believe this is the source of the bug because if I hack up the exported CSV file and change those field keys as above (e.g. from webform_sid to SID etc) then those field import correctly.

Some other standard webform fields are still not imported because (I'm guessing) those component values aren't defined in the above function.

image

leeksoup commented 1 year ago

@laryn @jenlampton - If my analysis is correct, I can probably fix this bug. I believe the key names in this function should match what is output in the download / export file. Please let me know if I should go ahead.

leeksoup commented 1 year ago

A similar problem occurs if I try to import using "Field Names" instead of "Field Form Keys."

image

As with key names, the upload / import Field Names don't seem to match the download / export ones.

Edited last line for clarity.

laryn commented 1 year ago

@leeksoup If you can make a PR that fixes some more of these to match webform defaults, I'm definitely open to it!

leeksoup commented 1 year ago

I believe that I have fixed this bug and the one in issue #5 but have uncovered another problem that prevents the import module from actually doing its job correctly. I'll do a PR on the fixes so far and then create a new issue for that problem.