1

Joomla 3.9.14

When I open a contact to edit their details and look in the browser console I can see the following notice;

[DOM] Found 2 elements with non-unique id #jform_id:  
(More info: https://goo.gl/9p2vKq) <input type=​"hidden" name=​"jform[id]​"
id=​"jform_id" value=​"115" class=​"readonly">​ <input type=​"hidden"
name=​"jform[id]​" id=​"jform_id" value=​"115" class=​"readonly">​

enter image description here

I haven't made any changes to core files or created overrides. The only thing I have done is create custom fields for my contacts.

What does this mean exactly and should I be concerned?

  • Few days ago I’v seen the same warning on one of my forms (in Chrome only) and it is just a warning about two elements with same ids. Related answer on this: stackoverflow.com/questions/47806187/… – Zollie Dec 20 '19 at 16:12
0

Not nearly enough info for me to make more than an educated guess, but is it possible you're editing the contact on the front-end? The contact form has the ID field defined as hidden on the front end, and if your template has a layout for that form that renders the fields of the form, and then adds a hidden element for the form's ID, that could cause it.

Why you're noticing it now despite it never being correct HTML to duplicate ID's, is that most browsers didn't start to care about the issue until the rise of javascript libraries and the single page app. The main thing duplicate IDs mess with is tacking javascript events on to elements. So long as the second occurrence has the correct value, the server will never know the difference; the browser will take the last value for a non-array field as gospel. We're finally emerging from the "no harm, no foul" approach to programming, so you can expect more of these notices to start showing up in your browser's console log. As an industry, we (web developers) have been way too sloppy for way too long.

Root cause for that message is something in the code is rendering the same field twice. Without more information I can't say with any degree of certainty where the duplication is coming from.

The reason behind my guess is the way the default_form.php file (components->com_contact->views->tmpl) is written in core Joomla. It walks through every field in the form, then adds a hidden field for the id manually after it all happens. I'm not in a position to test this at the moment, I'm afraid, but it's easily demonstrated by looking at the page source; if the first occurrance of the field is near the top of the form and the duplicated one is at the end, in the same div as the submit button, then that's probably the case.

(Working off memory here, so double-check me on this before believing me; my memory has failed me before, but I seem to remember wondering about this when chasing something else and then failed to go back and check it after the current crisis had been dealt with.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.