Download export file checkbox appears to be hidden even when you select Delimited text and have less than 500 (or other default number) submissions. This happens when PDF documents were selected by default.

Steps to reproduce:

1. Enabled Webform Entity Print (PDF) module
2. Create a webform
3. Submit form 11 or more times
4. Gt to the Results -> Download page
5. Select PDF documents as an export format
6. Hit save settings
7. Now select Delimited text as an export format
8. See that Download export file checkbox is not appearing at the download options fieldset

Here is a logic which makes this checkbox to be hidden:

    $form['export']['download']['download'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Download export file'),
      '#description' => $this->t('If checked, the export file will be automatically download to your local machine. If unchecked, the export file will be displayed as plain text within your browser.'),
      '#return_value' => TRUE,
      '#default_value' => $export_options['download'],
      '#access' => !$this->requiresBatch(),
      '#states' => $states_archive,
    ];

Checkbox does not appear because Download fieldset is generated once, but not per exporter. Also it is not getting rebuild in AJAX in case if Exporter format is changed.

The easiest solution would be to rebuild Download fieldset in AJAX on Exporter format change.

Also I noticed it does not work in other way, e.g. if you select Delimited text exported as a default and save it, and than select PDF exporter you can see that Download file checkbox getting hidden.

CommentFileSizeAuthor
#11 3119025-8.patch1.93 KBjrockowitz
#5 3119025-5.patch1.26 KBjrockowitz

Comments

dealancer created an issue. See original summary.

dealancer’s picture

Issue summary: View changes
jrockowitz’s picture

The issue is '#access' => !$this->requiresBatch(), because the batch size for PDFs is 10 and CSV is 500.

Rewriting the exporter form to use Ajax is not an easy task.

dealancer’s picture

@rockowitz, why do we need this checkbox at all? It looks like it is only used by CSV, but not JSON/YAML/PDF formatters. Why can't we make download checkbox set by default for CSV formatter?

jrockowitz’s picture

StatusFileSize
new1.26 KB

The compromise might be to use the default batch limit for the '#access'. The attached patch might be a good immediate solution.

The submission exporter code is 3 years old and might need some rethinking and refactoring.

jrockowitz’s picture

Status: Active » Needs review
dealancer’s picture

@jrockowitz

Thanks for the quick fix. This solution works on my local machine. Tomorrow I am going to test it in the real environment.

However, I was able to find another bug. When we hide this checkbox using "#access", another checkbox (Download uploaded files) gets disappeared automatically, but it should not. Can we ensure that the value of the Download checkbox is set to checked even if we hide it?

Also the naming and behavior of "Download export file" is confusing for a couple of reasons:

1. There is already a download button, so why do users need to check this checkbox?
2. It is even more confusing when this checkbox gets disappeared, it is quite hard to understand what should happen next: download or displaying export as a text in the browser instead.

I guess renaming this checkbox to "Display export as a plain text" would make more sense. What do you think?

jrockowitz’s picture

The attached patch handles the "Download uploaded files" checkbox. BTW, make sure you are using the latest dev release because Submission results can now be downloaded as ZIP file (or Tar archive) .

For now, I would rather not change any labels.

dealancer’s picture

Ok, so the solution works for me with version 5.6. Thank you so much.

Have not tried it with the recent dev version yet.

jrockowitz’s picture

I am using the current dev release so we should be fine. I will do one more round of manual review before committing the patch.

jrockowitz’s picture

StatusFileSize
new1.93 KB

Here is the slightly better patch for #8.

  • jrockowitz authored 538a865 on 8.x-5.x
    Issue #3119025 by jrockowitz: Download export file checkbox is hidden...
jrockowitz’s picture

Status: Needs review » Fixed

I manually tested the patch and it works as expected.

  • jrockowitz authored 538a865 on 6.x
    Issue #3119025 by jrockowitz: Download export file checkbox is hidden...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.