Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The JavaScript for repeatable subforms produces wrong id attributes #15187

Closed
saimiri opened this issue Apr 9, 2017 · 4 comments
Closed

The JavaScript for repeatable subforms produces wrong id attributes #15187

saimiri opened this issue Apr 9, 2017 · 4 comments

Comments

@saimiri
Copy link

saimiri commented Apr 9, 2017

I noticed a bug in the way the id attributes are created for repeatable subform fields in the JavaScript. On line 163 in subform-repeatable.js there is this:

id = name.replace(/(\]|\[\]$)/g, '').replace(/\[/g, '_')

which in the end produces id attributes like jform_contacts_contacts3_is_primary0. Unfortunately, the id attributes in the subform templates are in the format of jform_contacts__contactsX__is_primary, so the correct result should be something like jform_contacts__contacts3__is_primary0, with double underscores.

Because the id attribute doesn't match what is in the templates, the label elements get broken because their for attribute ends up being jform_contacts__contactsX__is_primary0 or similar, that is, the X does not get replaced.

A quick and dirty fix is to replace aforementioned line with

id = name.replace(/(\]\[)/g, '__').replace(/(\[)/g, '_').replace(/(\]$)/g, '')

but I'm sure there is a smarter way, too.

@Fedik
Copy link
Member

Fedik commented May 28, 2017

I can confirm the issue,
Additionally: <fieldset class="radio"> of radio buttons, also has "unfixed" id

@Fedik
Copy link
Member

Fedik commented Jun 3, 2017

@saimiri please test #16480

@joomla-cms-bot
Copy link

Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/15187

@ghost
Copy link

ghost commented Jun 3, 2017

closed as having PR #16480


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15187.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants