-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Subform "addrow" adds row with wrong id #12995
Comments
it not a bug, it feature 😄 but why do you think ID is wrong? 😉 |
indeed, it is a bug. It does not add random numbers but the rows length. Programming must follow some logic or it may become a mess for developers. It's just a matter of simplifying/minifying code, like in my case, where I'd need to get the right ID. The logical flow should be to add IDS sequentially. Actually, if you save it, rows will follow the sequence 1,2,3 .etc.. |
Agreed this is a bug, I recently had it with a custom form with subfields, but just wrote around it with my check doing an each opposed to looping through the max limit of possible sub forms as if you do a check for form0, form1, form2 then form1 would return nan and you would assume form2 no longer exists. We should +1 based off current loading sub form. |
Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/12995 |
See PR #19693 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/12995. |
Steps to reproduce the issue
Create a basic subform
<field name="lines" type="subform" formsource="/administrator/components/com_dummy/models/forms/line.xml" min="1" max="30" multiple="true" buttons="add,move,remove" layout="joomla.form.field.subform.repeatable-row" groupByFieldset="false" />
Expected result
When adding a row the new data-group id should be equal to the lenght of the subform rows to follow the last index id+1.
Actual result
The first added row data-group id will be equal to the last index +2. For example, if we have one row, the data-group id would be 0, then we add a new row and the data-group id of the recently created row will be 2.
<tr class="subform-repeatable-group" data-base-name="lines" data-group="lines0"..
<tr class="subform-repeatable-group" data-base-name="lines" data-group="lines2"..
System information (as much as possible)
Its a problem with the javascript subform-repeatable.js, on line 151 countnew is set to either lastRowNum+1 or count+1 which is always the rows length + 1. It should be rows.length to follow the logical sequence.
Additional comments
The text was updated successfully, but these errors were encountered: