In jQuery 1.7 attr methode doesn't accept property anymore and was fully replaced by prop. This break the field admin and possibly other things as well. When adding a field, you get the following error message, even when you select the correct widget.
Add new field: you need to select a widget.
We have this problem in various places.
A quick fix is to replace .attr to .prop like this.
/misc/states.js (solved #1448490: Remove the states.js overwrite as it was fixed upstream)
252: return this.prop('checked');
389: $(e.target).prop('checked', e.value);
/modules/field_ui/field_ui.js (harder because not a library)
93: $(this).html(html).prop('disabled', disabled );
246: $(ajaxElements).prop('disabled', true);
In comment #3 I propose instead to overrid jQuery's attr function.
This issue is coming from #1386294: Release jQuery 1.7 for Drupal 7.
Comment | File | Size | Author |
---|---|---|---|
#17 | 1448494_17_replace_field_ui_js.patch | 12.7 KB | gdd |
#9 | 1448494_3_replace_field_ui_js.patch | 12.58 KB | gagarine |
#8 | #1448494_3_replace_field_ui_js.patch | 12.58 KB | gagarine |
#7 | #1448494_3_replace_field_ui.js_.patch | 12.58 KB | gagarine |
#5 | #1448494_3 replace field_ui.js_.patch | 12.58 KB | gagarine |
Comments
Comment #1
rokr CreditAttribution: rokr commentedI tested these changes and can confirm this works. :-)
Comment #2
franzkewd CreditAttribution: franzkewd commentedTested this works. Cheers.
Comment #2.0
gagarine CreditAttribution: gagarine commentedUpdated issue summary.
Comment #3
gagarine CreditAttribution: gagarine commentedHacking the core is definitely not the way to go. I propose we Overrid jQuery's attr function instead with a backward compatible one. In short: attr function has to accept property and redirect them to prop.
I'm curious if http://www.bennadel.com/blog/1624-Ask-Ben-Overriding-Core-jQuery-Methods... will work in drupal environment.
Jquery 1.6.1 attr methods add a logic to make it backward compatible, we can check it for inspiration.
The big advantage, this will also works with contrib module. I don't think it will hit performance to badly.
EDIT
I first thought than we can use the same method than #1448490: Remove the states.js overwrite as it was fixed upstream. But field_ui.js is not added in drupal libraries so we can't access it via jquery_update_library_alter.
Comment #3.0
gagarine CreditAttribution: gagarine commentedUpdated issue summary.
Comment #4
gagarine CreditAttribution: gagarine commentedCorresponding Core issue #1494714: Add field_ui.js in drupal library (so it can be overwrited)
Comment #5
gagarine CreditAttribution: gagarine commentedHer a patch than simply replace field_ui.js with a working one. It's easy but I'm still thinking replacing the jQuery's attr function would be better.
Comment #6
hles CreditAttribution: hles commentedLink is not working !
Comment #7
gagarine CreditAttribution: gagarine commentedspace in name.. sorry
Comment #8
gagarine CreditAttribution: gagarine commentedWTF
Comment #9
gagarine CreditAttribution: gagarine commentedlast try.. (sorry for the spam)
EDIT
Ok this one works! so no # in file name... I will remember.
Comment #10
damontgomery CreditAttribution: damontgomery commentedgagarine,
Thanks for the work.
FYI, the patch naming convention is (module_name)-(description)-(issue_number)-(comment_number).patch.
for example, field_ui-replace-field-ui-js-1448494-3.patch.
Not sure how we should tackle this, but here is a link to an issue I'm working on which uses a conditional statement to preserve compatibility with jQuery pre 1.6, #1494860: Views Rewrite Results UI Broken using JQuery 1.7
Comment #11
gagarine CreditAttribution: gagarine commentedI created #1498858: [meta] attr and prop so we can discuss generally about the problem.
Need work because we need to replace the JS only for 1.7. I can just read the variable.
I will try to remember the convention... But why it's not documented right under the upload field :P
Comment #11.0
gagarine CreditAttribution: gagarine commentedadd link for states.js
Comment #12
jwilson3I've added the exact error message you get to the issue summary. As a work around for someone who needs 1.7 on the front end, but also needs to create new fields... just temporarily switch back to 1.5 in order to create the field, and then set it back to 1.7, from the Jquery Update admin UI ;)
Comment #13
Anonymous (not verified) CreditAttribution: Anonymous commentedI grappled with the best way to tackle this issue and ended up going with overriding front end jQuery with hook_js_alter() in my template.php to load jQuery 1.7.2 and using a separate backend end them to keep everything in working order. It's just a cleaner easier approach IMHO.
I am not sure if the hook_js_alter() method works with jQuery Update though (can a dev verify if it still works for jQuery UI update?), so your mileage may vary. I personally disabled jQuery Update.
Comment #14
zkday CreditAttribution: zkday commentedpatch #9 working with me! thanks.
Comment #15
hswong3i CreditAttribution: hswong3i commentedAlso confirm that #9 works for me too. Thank you very much ;-)
Comment #16
mrsinguyen CreditAttribution: mrsinguyen commentedThe patch #9 also works for me
Comment #17
gddHere's a reroll to current D7 head. It also fixes a documentation error.
Comment #18
gddI mean a reroll to current JQuery Update 2.2. Too much core dev going on in my life.
Comment #19
gagarine CreditAttribution: gagarine commentedIf this change passe in core this will works without change #1480568: use $.attr with false instead of empty string
Comment #20
ericduran CreditAttribution: ericduran commented@gagarine D7 isn't updating jquery to 1.7 any time soon. So this is still needed for D7.
Comment #21
gagarine CreditAttribution: gagarine commented@ericduran look at the patch in #6. I'm just correcting bad coding in field_ui.js than should make it compatible with all version of jquery.
Comment #22
MustangGB CreditAttribution: MustangGB commentedIf #1480568: use $.attr with false instead of empty string gets committed the issue is fixed in a much nicer way so this patch is redundant.
Comment #23
ericduran CreditAttribution: ericduran commentedYes, but it should be noted. The problem only shows up when running jquery_update so jquery_update introduces the issue and I think for now it should fix the issue.
When that problem is fixed in core that's fine but for now jquery_update should fix the problem it introduces. So lets get this fixed here, it'll be a lot faster.
Comment #24
gagarine CreditAttribution: gagarine commentedIt's bad code at the first time. We can work on a patch on this issue, but this would be stupid: in 2 weeks we can make an other patch than delete the work we eventually commit as the bug is going to be solve in core.
For now, if you want to help follow the other issue.
Comment #25
ericduran CreditAttribution: ericduran commented@gagarine I'm on the other issue, I completely undertand the issue is a code change in core. But I hate to be the one to say this but I highly doubt that is going to get fix in D8, back ported to D7 and release in 2 weeks. especially since the issue has been open for uhm 2 months now.
This is not a Major issue in core because the problem is only introduce when running the latest Jquery (1.7) which is why it should just be fixed here first!
Also bumping this up to critical as this is one of the most annoying issues now a days.
Comment #26
Anonymous (not verified) CreditAttribution: Anonymous commentedDoes this fix (#9 or #17) work for filefield uploads as well?
Comment #27
gagarine CreditAttribution: gagarine commentedOk everyone.. this is fixed in core now :).
So just wait the next drupal version and it will magically works..
http://drupalcode.org/project/drupal.git/commit/74de092
#1480568: use $.attr with false instead of empty string
@ericduran ok not 2 weeks... but 23 days ;).
Comment #28
klonosGreat news! Thanx ;)
Comment #29
ericduran CreditAttribution: ericduran commented@gagarine :-p :)
Comment #30
Stan.Ezersky CreditAttribution: Stan.Ezersky commented#27 Good news, friends! :)
@gagarine Great thanks!
Comment #31
jacobroufa CreditAttribution: jacobroufa commentedThanks @gagarine! :) +1
Comment #33
k_ CreditAttribution: k_ commentedupdated core to 7.15
re dl'd/installed a new/fresh jquery_update
did NOT apply patch #1448494
@ edit of a form, e.g. "/node/14/webform"
add a "Select list" field
select/open to edit
Select Options
attempt to edit (add, change, reorder) the available options ('one', 'two', 'three') -> nothing possible / nothing happens.
disable jquery_update, all's back to normal.
unclear atm whether it's the exact same issue, but ... definitely a jquery_update dependency again
EDIT:
applying the patch to 7.15 + jquery_update 2x-dev,
patch -p0 < ../1448494_3_replace_field_ui_js.patch
patching file jquery_update.module
patching file replace/modules/field_ui/field_ui.js
seems to have no effect on the @webform editing I'm trying. something different ... ?
Comment #34
gagarine CreditAttribution: gagarine commentedNot the same bug. Please open a new one.
Comment #34.0
gagarine CreditAttribution: gagarine commentedAdded the specific error message you get, for search purposes.
Comment #35
drecute CreditAttribution: drecute commentedThis affects drupal-6.x as well.