Download & Extend

Error: "Add existing field: you need to select a widget" when adding a field if jQuery is updated

Project:jQuery Update
Version:7.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:postponed

Issue Summary

Problem/Motivation

When jQuery is updated to, say, 1.6.x..

i got the title's problem when i try to create a new field.
The problem is that i select a new field name, then the type and i'd like to select the widget, but i cant because the input select it's like locked. i mean i cant click on the widget select, and if i save i get:
Add fieldname field: you need to select a widget

Original thread: http://drupal.org/node/1230142

Proposed resolution

In my point of view jquery update change the behavior of empty string. So here a patch

Index: modules/field_ui/field_ui.js
===================================================================
--- modules/field_ui/field_ui.js
+++ modules/field_ui/field_ui.js
@@ -86,7 +86,7 @@
       html += '<option value="' + value + '"' + (is_selected ? ' selected="selected"' : '') + '>' + text + '</option>';
     });

-    $(this).html(html).attr('disabled', disabled ? 'disabled' : '');
+    $(this).html(html).attr('disabled', disabled ? 'disabled' : false);
   });
};

Clément Hurel

Remaining tasks

Patch works for 1.4.x and newer versions of jQuery.

User interface changes

none.

API changes

none.

Original report by cavax

See http://drupal.org/node/1230142

Comments

#1

Status:active» closed (won't fix)

Core does not support jquery 1.6, upgrades to jquery are supported via this contrib module - http://drupal.org/project/jquery_update

#2

Project:Drupal core» jQuery Update
Version:7.9» 7.x-2.x-dev
Component:javascript» Code
Status:closed (won't fix)» postponed

This would require a replaced Javascript file for field_ui.js as part of jQuery Update for 7.x. Postponing on a release of jQuery Update that provides jQuery 1.6+.

#3

as per http://api.jquery.com/prop and http://blog.jquery.com/2011/05/12/jquery-1-6-1-released attached a new patch (for makefile users) using prop()

AttachmentSize
1327440-3.patch 524 bytes

#4

Version:7.x-2.x-dev» 6.x-2.0-alpha1

This patch needs to be applied for content.js file in Drupal 6 cck module when you upgraded jQuery in Drupal 6

#5

Same problem with jQuery Update version 7.x-2.x-dev from 2012-Jan-18 and Drupal 7.12. Downgrade to 7.x-2.2 solve the issue.
As alternative, patching Drupal module with drzraf patch from #3 solve the issue without downgrading jQuery Update to 7.x-2.2. Is this patch compartible with older jQuery, that comes with Drupal core? If yes, I think we must move this issue to Drupal core.

#6

Version:6.x-2.0-alpha1» 7.x-2.x-dev
Status:postponed» active

Few other related threads, like #1183358: Updating jQuery version breaks "disabled" attribute. As it is a JQuery 1.6+, it can only be applied to Drupal 8 or above, (and it is applied to Drupal 8 core).

So it is not a core issue, just a JQuery Update issue. Effects both D6 / D7, but general policy is to update the higher version and to back port, so re-tagging to 7.x-2.x-dev.

#7

Status:active» postponed

Duh. The module doesn't officially support this JQuery version.

But it does fix the error if you are running a higher version, and I would give it the RTBTC otherwise

#8

If like me you don't like applying patches to core modules it can be resolved with a hook. I simply copied the modules/field_ui/field_ui.js file to my custom module, applied the modifications the patch above does and added this to my code.

<?php
function mymodule_form_field_ui_field_overview_form_alter(&$form, &$form_state, $form_id) {
    if(isset(
$form['#attached']['js'])){
        if(
is_array($form['#attached']['js'])){
            foreach(
$form['#attached']['js'] as $index => &$js){
                if(!
is_array($js) && $js == 'modules/field_ui/field_ui.js'){
                   
$js = drupal_get_path('module', 'mymodule') . '/field_ui.js';
                }
            }
        }
    }
}
?>

cheers !

#9

the patch in 3 worked for me

nobody click here