Module takes over and breaks the editor_file upload dialog box.

Within file_upload_options_element_info_alter the editor_file the editor_file callback is overwritten. Then within file_upload_options_file_managed_file_save_upload the call to getEntity() dies because the passed "EditorFileDialog" is not an entity.

Comments

d8v15 created an issue. See original summary.

imclean’s picture

Status: Needs work » Postponed (maintainer needs more info)

This module takes over file handling as that is how it is designed to work. While it does get around core's limitations using the standard "replace" option, it won't necessarily work in every case.

I don't use the module you mention. Could you propose a solution submit a patch for me to review?

imclean’s picture

Status: Postponed (maintainer needs more info) » Active

I think I see the problem. It's not always an entity, it might be a field definition.

imclean’s picture

This is probably the same issue I'm having with fillpdf. The issue is we're looking for an entity with a file field which doesn't work if a field is defined in code.

In the case of fillpdf, the overview form is simply defining a managed file field. Is this the case with the editor_file module?

There are a couple of options.

  1. Ignore file fields not attached to an entity
  2. Allow upload options to be configured on the field itself when submitting the file
imclean’s picture

A 3rd option would be to specify an arbitrary field name within File Upload Options settings. This might be the cleanest method.

imclean’s picture

Status: Active » Needs review

Try this.

  • Allows adding custom fields by name (e.g. "field_file")
  • Fields will automatically be added with the current default the first time a form is viewed
  • The action to take with automatically added fields can be changed in the settings /admin/config/media/file-upload-options
imclean’s picture

StatusFileSize
new8.08 KB

A patch would help.

imclean’s picture

Version: 8.x-1.0-alpha1 » 8.x-1.x-dev
StatusFileSize
new8.1 KB

Missed a couple of things.

imclean’s picture

Status: Needs review » Needs work
+++ b/file_upload_options.module
@@ -56,7 +93,14 @@ function file_upload_options_form_alter(&$form, FormStateInterface $form_state,
+  if (array_key_exists('#entity_tpe', $element)) {

Typo.

imclean’s picture

Status: Needs work » Needs review

@d8v15 please test with editor_file.

Steps:

  1. Apply this patch
  2. Clear cache
  3. Use file editor as normal

Once this works, and you have viewed an editor_file file upload field, you can then configure the behaviour at /admin/config/media/file-upload-options.

imclean’s picture

StatusFileSize
new7.91 KB
imclean’s picture

StatusFileSize
new7.93 KB

  • imclean committed 0d7f79b on 8.x-1.x
    Issue #3132525 by imclean: Module conflicts with editor_file module
    
imclean’s picture

I've committed anyway. Please try development version.

imclean’s picture

Status: Needs review » Fixed

Open a follow up issue if there are any problems.

imclean’s picture

Status: Fixed » Closed (fixed)