Skip to content

Conversation

@ankushmaherwal
Copy link
Contributor

Pull Request for Issue #25387

Summary of Changes

The value of id attribute of input element is checked for non-word characters and if non-word characters are found then replacing with them with underscore

Testing Instructions

Check the value of id attribute of input element in repetable subform after clicking the plus (+) button to add new clone of sub-form

Expected result

The value of id attribute of input element should not contain any non-word character

Actual result

The non-word characters in the value of id attribute of input element are being replaced with underscore

Documentation Changes Required

no change required in documentation

id = name.replace(/(\[\]$)/g, '').replace(/(\]\[)/g, '__').replace(/\[/g, '_').replace(/\]/g, ''), // id from name
nameNew = name.replace('[' + group + '][', '['+ groupnew +']['), // New name
idNew = id.replace(group, groupnew), // Count new id
idNew = id.replace(group, groupnew).replace(/[\W]+/g,"_"), // Count new id and replace non-word characters in name with underscore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modify id instead of idNew so labels work properly. Also multiple characters should probably be replaced by multiple underscores.

E.g. in PHP Test (optional) field generates jform_com_fields__repeat__repeat0__Test__optional_. Now in JS it generates jform_com_fields__repeat__repeat0__Test_optional_.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have modified the id instead of idNew also now multiple non-word characters are replaced with underscores

var $el = $(haveName[i]),
name = $el.attr('name'),
id = name.replace(/(\[\]$)/g, '').replace(/(\]\[)/g, '__').replace(/\[/g, '_').replace(/\]/g, ''), // id from name
id = name.replace(/(\[\]$)/g, '').replace(/(\]\[)/g, '__').replace(/\[/g, '_').replace(/\]/g, '').replace(/\W/g,"_"), // id from name
Copy link
Contributor

@SharkyKZ SharkyKZ Jul 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codestyle.

Suggested change
id = name.replace(/(\[\]$)/g, '').replace(/(\]\[)/g, '__').replace(/\[/g, '_').replace(/\]/g, '').replace(/\W/g,"_"), // id from name
id = name.replace(/(\[\]$)/g, '').replace(/(\]\[)/g, '__').replace(/\[/g, '_').replace(/\]/g, '').replace(/\W/g, '_'), // id from name

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the Codestyle

@ghost
Copy link

ghost commented Jul 2, 2019

@SharkyKZ
Copy link
Contributor

SharkyKZ commented Jul 2, 2019

Now you need to generate a minified file (media/system/js/subform-repeatable.js).

@ankush-maherwal
Copy link

updated the related minified js file

@manojLondhe
Copy link
Contributor

@SharkyKZ what tools shall be used for minification?

@Quy
Copy link
Contributor

Quy commented Jul 2, 2019

@SharkyKZ
Copy link
Contributor

SharkyKZ commented Jul 2, 2019

Is manually modified minified file fine in this case?

@ankushmaherwal
Copy link
Contributor Author

as of now I have manually modified the minified JS

@richard67
Copy link
Member

@richard67
Copy link
Member

I have tested this item ✅ successfully on 9570c0d

Solves both issues #25387 and #25384 .


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

@HLeithner HLeithner merged commit fea05e2 into joomla:staging Jul 2, 2019
@HLeithner
Copy link
Member

thx

@HLeithner HLeithner added this to the Joomla 3.9.9 milestone Jul 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants