I've noticed this issue in a project of ours, after a little project specific code debugging I wondered if this wasn't a core issue. Therefor I quickly installed a pure D7.40 setup.

Steps to reproduce

  1. Download Drupal 7.40
  2. Install Drupal 7.40 with the "standard"-installation profile
  3. Create a new image field on `Basic page` with value limit "unlimited"
  4. Go to the "Add new Basic page"
  5. Select a image from your local machine, DO NOT CLICK "UPLOAD"-BUTTON
  6. Without filling in the required Title field (to trigger a required error message), click on Save
  7. Note that the image field is now missing it's input field, rendering it impossible to use at this point.

The weirdest thing is, if you DO click the "Upload"-button in the above process and THEN save the node, it WILL show the input field.

Environment

OS: Mac OS X 10.10.3
PHP: PHP 5.5.20
MySQL: 5.6.24 Source distribution

Comments

Ambidex created an issue. See original summary.

lhuria94’s picture

Hi Ambidex,

I did just tried to reproduce the issue with D 7.40 standard profile.
Added a image field in Basic page content type.

Then tried to save without filling the mandatory title and without uploading the image, just selected the image from local machine.

Image gets uploaded as you can see in the screenshot. Yes now i can see the issue. Input field just disappeared.
Looks like a file field issue. I was not able to reproduce it first. Thats why i wrote this comment.

After commenting, I was able to reproduce. Will get back to you after taking a look at the issue.

priya.chat’s picture

StatusFileSize
new413 bytes

Hello Ambidex,

I have go through all the steps that you have written and able to reproduce the issue with Drupal 7.40 with the "standard"-installation profile .

As I notice your problem is that the image input form field will disappear on error page when node form is submitted with Save button.

I have added a patch to solve this issue. Please review the patch.

dcam’s picture

Issue tags: -Fields in Core +JavaScript

Tagging this issue properly so it will get noticed by the JS maintainers.

dcam’s picture

Status: Active » Needs review

Also, @priya.chat when you upload a patch if you set the issue status to Needs review then it will trigger Testbot to automatically test it.

Status: Needs review » Needs work

The last submitted patch, 3: 2594653-1-7.40.patch, failed testing.

droplet’s picture

Version: 7.4 » 8.0.x-dev
Issue tags: +Novice, +js-novice, +Needs reroll, +Needs manual testing
rpayanm’s picture

Version: 8.0.x-dev » 7.x-dev

In drupal 8 don't exist this issue.

Status: Needs work » Needs review

rpayanm queued 3: 2594653-1-7.40.patch for re-testing.

vijeta14’s picture

Hi @priya.chat

As i can see you patch work, but this patch causes the file to remove on submit. File should be uploaded and there should be option to upload another ideally.

Thoughts?

swarad07’s picture

The patch in #3 applied cleanly for me on 7.x-dev.

However, the patches does not fix the issue for me. Attaching the screenshot after applying patch.

// Only disable upload fields for Ajax buttons.
-    if (!$(clickedButton).hasClass('ajax-processed')) {
+    if ($(clickedButton).hasClass('ajax-processed')) {
       return;
     }

It would be great if someone can review the above code and confirm if it is right place to fix the issue.

swarad07’s picture

Status: Needs review » Needs work
natanmoraes’s picture

I'm having the same problem with the File field with unlimited values on Drupal 7.41.

The patch in #3 does solve the problem with the missing input but the selected file doesn't get uploaded.

natanmoraes’s picture

Title: Image file-input field disappears under certain circumstances » File-input field disappears under certain circumstances
Component: image system » field system
Issue tags: -JavaScript, -Novice, -js-novice, -Needs reroll

I couldn't find where is the problem that causes this issue neither a way to resolve it but, from my debugging, it seems that the file widget is not being rendered properly when the form goes through the validation process because the functions that would build it (file_field_widget_form for instance) are not called at that moment and Drupal doesn't seem to know there's an extra element (the field input) that needs to be rendered.

Since this is an issue with the file upload in general, and the fix doesn't seem to be on javascript, I'm removing the js and novice related tags

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.