When there is only a single editable element and the submit button for said element is hidden, the jQuery selector is not specific enough. If the field itself has any submit buttons in it (e.g. commentfield) those buttons are hidden as well.

The field below should have a remove and an add new comment button:
Missing buttons

Like so:
Visibile buttons

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

BassistJimmyJam’s picture

Status: Active » Needs review
FileSize
815 bytes

Attached is a patch. I added the results of the selector to find the submit button to hide to a variable and am using that to hide and trigger the button on change. This allows the element to be used in both places without having to search for it each time.

micheas’s picture

FileSize
973 bytes

This whole concept of hiding submit buttons should probably be scrapped and rethought.

IE9 and some of the latest versions of chrome do not submit content attached to hidden fields.

This means that the ajax is unbound and you get json output to either save (IE) or in your browser window (chrome).

I had a late night inspiration that resulted in the attached patch.

The patch has at least one issue that I can see. it doesn't account for borders that are set on the submit button.

johnv’s picture

Title: Hiding submit button is not specific enough » Hiding 'Submit'-button is not specific enough

The same problem happens for files, not only for texts. See #1321304: Hiding 'Submit'-button is not specific enough for multiple-value File field which contains the following 'patch':

--- editablefields.js	(revision 695)
+++ editablefields.js	(working copy)
@@ -6,6 +6,8 @@
 
       // There is only one editable field in that form, we can hide the submit
       // button.
+      if ($this.find('input[type=file]')) {
+      } else
       if ($this.find('input[type=text],textarea,select').length == 1 || $this.find('input[type=radio] ').length > 1) {
         $this.find('input.form-submit').hide();
         $this.find('input[type=text],input[type=radio],textarea,select').change(function() {

tim.plunkett’s picture

Title: Hiding 'Submit'-button is not specific enough » Hiding submit button is not specific enough
Status: Needs review » Needs work
+++ b/editablefields.jsundefined
@@ -7,8 +7,13 @@ Drupal.behaviors.editablefields_submit = {
+        $this.find('.use-ajax').css('display','none');

I don't understand why .hide() wouldn't work here, and if it doesn't, .addClass('element-hidden') would be better anyway.

See element-hidden and element-invisible: http://drupalcode.org/project/drupal.git/blob/refs/heads/8.x:/core/modul...

micheas’s picture

IE 9 and chrome 19 do not submit form elements that have css of display:none;

.hide() and .css('display','none') and .addClass('element-hidden') ALL fail on IE9 and chrome 19.

This is apparently something to do with some specific malware.

Personally I think the browsers are going about fixing the problem the wrong way, but from a practical standpoint, if you support IE9 and the next version of chrome, you have to accept that display:none on form elements is not going to work anymore.

micheas’s picture

Actually, based on a conversation on IRC #drupal-contribute we should be adding the class "element-invisible" to the buttons we want hidden.

modules/system/system.base.css has element-invisible defined in addition to element-hidden because of form issues with hidden fields.

robby.griffin’s picture

Status: Needs work » Needs review
FileSize
1.23 KB

I needed to make file fields easier to use, so I added some JQuery logic to ajaxify file fields. There are probably a lot of improvements to be made, and there seems to be an issue if you upload multiple files in a row where Drupal doesn't reload the "Add New File" widget, but it seems to work great for my purposes, and I would love to get some feedback on it.

dags’s picture

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

I realize this issue has been stale for quite some time but where do we stand on this? Is the patch in #2 good except for replacing .add('display', 'none') with .addClass('element-hidden')?

@robby.griffin seems like your patch is addressing a similar - but different - issue. Would you mind opening a new issue describing why the patch is needed and post it in there. Thanks!