?
avatar xabispacebiker
xabispacebiker
24 Nov 2016

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

avatar xabispacebiker xabispacebiker - open - 24 Nov 2016
avatar joomla-cms-bot joomla-cms-bot - change - 24 Nov 2016
Labels Added: ?
avatar xabispacebiker xabispacebiker - change - 24 Nov 2016
The description was changed
avatar xabispacebiker xabispacebiker - edited - 24 Nov 2016
avatar xabispacebiker xabispacebiker - change - 24 Nov 2016
The description was changed
avatar xabispacebiker xabispacebiker - edited - 24 Nov 2016
avatar xabispacebiker xabispacebiker - change - 24 Nov 2016
The description was changed
avatar xabispacebiker xabispacebiker - edited - 24 Nov 2016
avatar xabispacebiker xabispacebiker - change - 24 Nov 2016
The description was changed
avatar xabispacebiker xabispacebiker - edited - 24 Nov 2016
avatar xabispacebiker xabispacebiker - change - 24 Nov 2016
The description was changed
avatar xabispacebiker xabispacebiker - edited - 24 Nov 2016
avatar xabispacebiker xabispacebiker - change - 24 Nov 2016
The description was changed
avatar xabispacebiker xabispacebiker - edited - 24 Nov 2016
avatar xabispacebiker xabispacebiker - change - 24 Nov 2016
The description was changed
avatar xabispacebiker xabispacebiker - edited - 24 Nov 2016
avatar xabispacebiker xabispacebiker - change - 24 Nov 2016
The description was changed
avatar xabispacebiker xabispacebiker - edited - 24 Nov 2016
avatar Fedik
Fedik - comment - 24 Nov 2016

it not a bug, it feature 😄

but why do you think ID is wrong? 😉
there each ID are unique, there no duplication, so all fine. If it does not go 1.2.3...X does not meant it is wrong 😉
Even more, if you start add/remove/move rows, then the numbers order will become even more random 😉

avatar xabispacebiker
xabispacebiker - comment - 25 Nov 2016

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, as in my case where I'd need to get the right ID without having to do a lot of checks in my code. The logical flow should be to add IDS sequentially. Actually, if you save it, rows will follow the sequence 1,2,3 .etc..

avatar tonypartridge
tonypartridge - comment - 3 Dec 2016

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.

avatar brianteeman brianteeman - change - 8 Dec 2016
Category Fields
avatar franz-wohlkoenig franz-wohlkoenig - change - 5 Apr 2017
Priority Medium Low
Status New Confirmed
avatar franz-wohlkoenig franz-wohlkoenig - change - 8 Nov 2017
Status Confirmed Discussion
avatar brianteeman brianteeman - labeled - 25 Mar 2018
avatar Quy Quy - change - 20 Apr 2018
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2018-04-20 20:13:32
Closed_By Quy
avatar joomla-cms-bot joomla-cms-bot - change - 20 Apr 2018
Status Closed Discussion
avatar joomla-cms-bot joomla-cms-bot - change - 20 Apr 2018
Status Discussion Closed
Closed_Date 2018-04-20 20:13:32 2018-04-20 20:13:33
Closed_By Quy joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - unlabeled - 20 Apr 2018
avatar joomla-cms-bot joomla-cms-bot - close - 20 Apr 2018
avatar joomla-cms-bot
joomla-cms-bot - comment - 20 Apr 2018

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

avatar Quy
Quy - comment - 20 Apr 2018

See PR #19693


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

Add a Comment

Login with GitHub to post a comment